运行Springcloud项目出现下面错误:
Description:
No spring.config.import property has been defined
Action:
Add a spring.config.import=nacos: property to your configuration.
If configuration is not required add spring.config.import=optional:nacos: instead.
To disable this check, set spring.cloud.nacos.config.import-check.enabled=false.
我的环境是:
springboot:3.2.4
SpringCloud:2023.0.0
nacos:2.3.0
解决这个问题:
先检查时是否导入对应的包
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId></dependency><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-bootstrap</artifactId></dependency>
我的问题是缺失:spring-cloud-starter-bootstrap 包
检查配置:
是否有bootstrap.yml文件
文件配置的内容是否正确,下面是我的配置:
spring:cloud:nacos:discovery:server-addr: 192.168.1.123:8848config:server-addr: 192.168.1.123:8848file-extension: yaml
上面是我的排查问题思路