Different behavior of spring.cloud.bootstrap.location since Spring Boot 2

 ̄綄美尐妖づ 提交于 2020-01-25 07:30:51

问题


I noticed a different behavior of the property spring.cloud.bootstrap.location since Spring Boot 2.x

Behavior in Spring Boot 1.x:

  • Build in bootstrap.properties file inside the JAR is regarded
  • Specified bootstrap.properties file is regarded

Behavior in Spring Boot 2.x:

  • Build in bootstrap.properties file inside the JAR is not regarded
  • Specified bootstrap.properties file is regarded

Reason is that since Spring Boot 2 the behavior of the spring.config.location configuration has been fixed and the property spring.cloud.bootstrap.location works now also as desired.

See https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Migration-Guide#configuration-location

I restored the origin behavior by adding the default search locations to the property in addition spring.cloud.bootstrap.location=classpath:/,classpath:/config/,file:./,file:./config/,file:/my/special/search/location

Should there be introduced also a new property spring.cloud.bootstrap.additional-location like the spring.config.additional-location?

Hint: This is how the BootstrapApplicationListener currently works:

https://github.com/spring-cloud/spring-cloud-commons/blob/57c2f9a154f3d4146135529261f071a00ab47ea9/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/BootstrapApplicationListener.java#L145-L156

来源:https://stackoverflow.com/questions/54204333/different-behavior-of-spring-cloud-bootstrap-location-since-spring-boot-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!