Toa*_*Dao 3 java spring spring-boot
所以我只是在玩Spring Boot 2.0.4,我今天注意到了这一点。不知道我错过了什么。请帮我检查一下。
春季申请
@SpringBootApplication
@EnableScheduling
public class Application extends SpringBootServletInitializer {
Run Code Online (Sandbox Code Playgroud)
application.properties(位于src / main / resources中)
server.port=8088
Run Code Online (Sandbox Code Playgroud)
使用Intellij启动项目
2018-08-17 12:11:05 INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): 8088 (http) with context path ''
Run Code Online (Sandbox Code Playgroud)
使用java命令行启动项目:
java -jar sample.jar --spring.config.location=D:\config\ --spring.profiles.active=dev
Run Code Online (Sandbox Code Playgroud)
应用程序未使用配置的端口
2018-08-17 11:25:25 INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): 8080 (http) with context path ''
Run Code Online (Sandbox Code Playgroud)
看起来Spring Boot 2.0忽略了默认属性文件(请注意:此配置仅在applications.properties中,其他位置无,因此不会与其他配置文件重叠)
您指定spring.config.location启动uber-jar并从Spring Boot 2启动,指定此参数替换Spring所使用的默认位置,如文档中所述。
当使用来配置自定义配置位置时
spring.config.location,它们将替换默认位置。例如,如果spring.config.location配置了的值classpath:/custom-config/,file:./custom-config/,搜索顺序变为下式:
file:./custom-config/
classpath:custom-config/
因此,我认为您必须显式添加application.propertiesin spring.config.location:
--spring.config.location=D:\config\,classpath:\application.properties
Run Code Online (Sandbox Code Playgroud)
或者作为替代用途,spring.config.additional-location例如--spring.config.additional-location=D:\config\ 代替spring.config.location它将增加而不是替换文档中所述的位置:
另外,当使用spring.config.additional-location配置自定义配置位置时,除默认位置外,还会使用它们。
| 归档时间: |
|
| 查看次数: |
2248 次 |
| 最近记录: |