Closed liucyu closed 5 years ago
Which version of spring cloud alibaba and nacos server are you using?
版本 springboot 2.1.4.RELEASE springcloud Greenwich.SR1 spring-cloud-starter-alibaba-nacos-config 0.2.1.RELEASE @fangjian0423
Spring Cloud Greenwich should use spring-cloud-starter-alibaba-nacos-config 0.9.0.RELEASE, refer https://github.com/spring-cloud-incubator/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E.
@fangjian0423 still not work....
hi, did you solve it?
I think you can debug in NacosPropertySourceLocator
to see what happened if didn't solve it.
NacosPropertySourceLocator.loadApplicationConfiguration当使用loadNacosDataIfPresent你会发现我们的dataid会被修改成dataid.file-extension,所以用nacos新建配置的时候命名要是nacos-config.properties
步骤
结果
拿不到配置,但是如果按照纯Java方式却能获取到配置
bootstrap.properties
:spring.application.name=nacos-config
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
日志
2019-05-29 16:44:12.704 INFO 65456 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource {name='NACOS', propertySources=[NacosPropertySource {name='nacos-config.properties'}]}
代码
结果 __