1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > SpringCloud项目中无法识别bootstrap.yml的问题

SpringCloud项目中无法识别bootstrap.yml的问题

时间:2022-02-28 06:09:10

相关推荐

SpringCloud项目中无法识别bootstrap.yml的问题

使用版本

<!-- SpringCloud 微服务 --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>.0.1</version><type>pom</type><scope>import</scope></dependency>

原因

官方文档中提到了如果要使用bootstrap.yml,需要开启spring.cloud.bootstrap.enabled=true或者引入spring-cloud-starter-bootstrap原文链接Config First Bootstrap,但是开启变量需要环境变量或者系统变量这显然不适合我们用作开发

To use the legacy bootstrap way of connecting to Config Server, bootstrap must be enabled via a property or the spring-cloud-starter-bootstrap starter. The property is spring.cloud.bootstrap.enabled=true. It must be set as a System Property or environment variable.

<!-- bootstrap 启动器 --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-bootstrap</artifactId></dependency>

拓展

在学习github开源项目mall-swarm时发现其并没有引用spring-cloud-starter-bootstrap也可以正常识别bootstarp.yml,此项目中使用的版本为Hoxton.SR5,查找到对应版本的文档Config First Bootstrap发现此版本并没有这样的要求,推断可能是默认开启的

The default behavior for any application that has the Spring Cloud Config Client on the classpath is as follows: When a config client starts, it binds to the Config Server (through the spring.cloud.config.uri bootstrap configuration property) and initializes Spring Environment with remote property sources.

<!-- SpringCloud 微服务 --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>Hoxton.SR5</version><type>pom</type><scope>import</scope></dependency>

参考

/flying607/p/14657543.html

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。