@NacosValue没有优先读nacos的配置
seeping007 opened this issue · comments
使用 @NacosValue(包括@value)注解,若本地application.yaml有相应配置,则不会读nacos上的配置,需要把application.yaml对应配置去掉才行。
nacos-config-spring-boot-starter 0.2.10版本没有这个问题。是因为版本不匹配?还是说配置上有了一定变更?
相应版本如下:
- nacos-server:2.1.0
- nacos-config-spring-boot-starter:0.2.12
- springboot:2.7.3(2.6.3)
- springcloud:2021.0.3(2021.0.1)
- jdk:17
bootstrap.yaml相关配置:
nacos:
config:
enabled: true
bootstrap:
enable: true
max-retry: 10
auto-refresh: true
remote-first: true
type: yaml
用官方推荐的方式,不使用bootstrap引入就可以(nacos.config移到application.yaml)
- https://github.com/alibaba/spring-cloud-alibaba/blob/2021.x/spring-cloud-alibaba-docs/src/main/asciidoc-zh/sca-upgrade-guide.adoc
- 抛弃 bootstrap 引入配置的方式,使用 spring.config.import 方式引入配置,spring boot 2.4 对这一块做了很大的优化工作,不再需要全量启动一个容器来刷新配置