草庐IT

Spring Boot 单页应用程序 - 将每个请求转发到 index.html

我有一个SpringBoot(v1.3.6)单页应用程序(angular2),我想将所有请求转发到index.html。对http://localhost:8080/index.html的请求正在工作(200,我得到了index.html)但是http://localhost:8080/home不是(404)。Runner.class@SpringBootApplication@ComponentScan({"packagea.packageb"})@EnableAutoConfigurationpublicclassRunner{publicstaticvoidmain(String

java - spring-boot 中的默认调度程序池大小是多少?

我正在使用spring-boot和@Scheduled注解来执行一些任务。如何知道spring-boot中默认的定时任务池大小是多少?原因:下面的类没有并行执行作业,而是一个接一个地执行。可能默认只配置了单线程执行器?@ServicepublicclassZipFileTesterAsync{@Scheduled(fixedDelay=60000,initialDelay=500)publicvoidrun()throwsException{System.out.println("import1");TimeUnit.MINUTES.sleep(1);System.out.printl

java - Spring-Boot 中 application.properties 属性的 UTF-8 编码

在我的application.properties我添加了一些自定义属性。custom.mail.property.subject-message=Thisisaäöüßproblem在这个类中,我有自定义属性的表示。@Component@ConfigurationProperties(prefix="custom.mail.property")publicclassMailProperties{privateStringsubjectMessage;publicStringgetSubjectMessage(){returnsubjectMessage;}publicvoidsetS

spring - 使用 Spring Boot 的 Hibernate Envers - 配置

我正在尝试设置HibernateEnvers以使用我的SpringBoot应用程序。我已经包含了Envers依赖项并添加了@Audited注释,它工作正常,但我无法配置特定的Envers属性,SpringBoot似乎没有选择它们。具体来说,我尝试通过将审计表放入application.properties来为审计表设置不同的数据库架构,但没有运气:hibernate.envers.default_schema=app_audit或org.hibernate.envers.default_schema=app_audit或spring.jpa.hibernate.envers.defau

java - 当我只想使用 RestTemplate 时如何防止在 Spring Boot 中自动启动 tomcat/jetty

我想通过在SpringBoot应用程序中包含工件来使用RestTemplate/TestRestTemplateorg.springframeworkspring-web但这会自动启动Tomcat或Jetty。有没有办法关闭它,或者不包括上述工件。TestRestTemplate在引导工件中,但不在基本RestTemplate中。 最佳答案 如果Web容器不存在,SpringBoot不会启动它。spring-web不提供任何嵌入式容器。您可能想要分析项目的依赖关系(尝试mvndependency:tree)。如果你想确保你的spri

spring - 为什么 Spring Boot 在 Mac OSX Mavericks (10.9.2) 上启动非常慢?

我对java没有任何其他问题,并且STS可以正常启动,但是当我尝试将我的应用程序作为"RunasSpringBootApp"(或任何示例)运行时,在我得到熟悉的“SpringBoot”ASCII艺术之前,控制台最多空了5分钟。然后就可以正常使用了。 最佳答案 原来存在解决网络主机的问题。我通过从控制台执行此命令来修复它:scutil--setHostName"localhost" 关于spring-为什么SpringBoot在MacOSXMavericks(10.9.2)上启动非常慢?,

java - 集成测试的 Spring Boot 身份验证

我正在尝试为我的Controller运行集成测试,但如果我不进行身份验证,我会遇到问题。这是我的Controller:@RunWith(SpringRunner.class)@SpringBootTest(webEnvironment=SpringBootTest.WebEnvironment.RANDOM_PORT)@TestPropertySource(properties={"security.basic.enabled=false","management.security.enabled=false"})@EnableAutoConfiguration(exclude={or

spring-boot-starter-tomcat 与 spring-boot-starter-web

我正在尝试学习SpringBoot,但我注意到有两种选择。spring-boot-starter-web-根据文档,它支持全栈Web开发,包括Tomcat和web-mvcspring-boot-starter-tomcat既然#1支持Tomcat,为什么还要使用#2?有什么区别?谢谢 最佳答案 Since#1supportsTomcatwhywouldonewanttouse#2?spring-boot-starter-web包含spring-boot-starter-tomcat。如果不需要springmvc(包含在spring-

java - 为什么 Spring Boot 2.0 应用程序不运行 schema.sql?

当我使用SpringBoot1.5时,在应用程序启动时,当设置了适当的配置时,Hibernate会执行位于/resources文件夹中的schema.sql文件。在SpringBoot2.0发布后,此功能不再起作用。我在文档中找不到有关此更改的任何信息。这是我的application.properties文件内容:spring.datasource.url=...spring.datasource.username=...spring.datasource.password=...#spring.jpa.hibernate.ddl-auto=create-dropspring.jpa.

java - Spring Boot 1.4 测试 : Configuration error: found multiple declarations of @BootstrapWith

按照此处的官方文档:http://docs.spring.io/spring-boot/docs/1.4.0.M2/reference/htmlsingle/#Testing我想像这样测试我的一种RESTAPI方法:@RunWith(SpringRunner.class)@WebMvcTest(LoginController.class)@SpringBootTest(classes=Application.class)publicclassAuthorizationServiceTest{@AutowiredprivateTestRestTemplaterestTemplate;@T