nacos做配置中心,读取不到nacos的配置,项目启动报错,发现是因为bootstrap.properties根本没有加载。发现原因是
2020版本以后,添加spring-cloud-context是没有用的,因为官方重构了bootstrap引导配置的加载方式
需要增加如下依赖:
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-bootstrap</artifactId> </dependency>
详细报错:
c.a.cloud.nacos.NacosConfigProperties : create config service error!properties=NacosConfigProperties{serverAddr='null', encode='null', group='DEFAULT_GROUP', prefix='null', fileExtension='properties', timeout=3000, endpoint='null', namespace='null', accessKey='null', secretKey='null', contextPath='null', clusterName='null', name='null', sharedDataids='null', refreshableDataids='null', extConfig=null}