我试图bootstrap.properties
从我的罐子外面放,所以它不会被其他开发人员错误地覆盖。你能在这里给点建议吗?
这是它的内容 - 指向 spring 服务器配置
# application name
spring.application.name=elixium
# The server entry point
spring.cloud.config.uri=http://localhost:8888
我试图bootstrap.properties
从我的罐子外面放,所以它不会被其他开发人员错误地覆盖。你能在这里给点建议吗?
这是它的内容 - 指向 spring 服务器配置
# application name
spring.application.name=elixium
# The server entry point
spring.cloud.config.uri=http://localhost:8888
Spring Cloud 使用与spring boot 相同的位置来查找bootstrap.properties
(或.yml
)。所以classpath:,classpath:/config,file:,file:config/
是默认搜索路径,./config/
是最高优先级。如果您的文件在其中,./config
或者./
它应该可以正常工作。更改位置的属性 ( spring.cloud.bootstrap.location
) 与引导稍有不同。
spring.cloud.bootstrap.location
行为类似于spring.config.location
(在 Spring Boot 2 中),它替换了这些配置文件的位置。
为了使其工作,它必须定义为系统属性。
例如 :
用罐子:
java -jar
-Dspring.cloud.bootstrap.location=anyLocation/bootstrap.yml
...
使用 Spring Boot maven 插件:
mvn spring-boot:run
-Dspring-boot.run.jvmArguments="-Dspring.cloud.bootstrap.location=anyLocation/bootstrap.yml"