之前用nacos配置中心都是bootstrap>application的,引了一个新项目cloud版本2021.0.1.0,发现bootstrap加载远远小于application,查询后得知Spring Cloud 2020以后的版本bootstrap 加载优先级并没有高于 application,反而application是最高的,若使bootstrap起作用并优先加载需要引入bootstrap包依赖。
<!-- 微服务配置中心nacos -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>