報(bào)錯信息如下
Description:
No spring.config.import property has been defined
Spring 官方給出的解決方案如下
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.
這里只嘗試了第一種解決方案:
首先,2021.0.5版本的 Spring Cloud 默認(rèn)不再啟用 bootstrap 包,因此應(yīng)該將配置文件寫在 application.yml 中,或手動在 maven 中導(dǎo)入 bootstrap 包
然后,在 application.yml 中,按照以下方式配置文章來源:http://www.zghlxwxcb.cn/news/detail-513404.html
spring:
application:
name: XXXX
cloud:
nacos:
server-addr: XX.XX.XX.XX:8848
config:
group: XXXX
namespace: XXXX
# SpringCloud 2021版本之后,需要用以下方式導(dǎo)入nacos的配置文件
config:
import: nacos:XXXX.yml
問題解決。文章來源地址http://www.zghlxwxcb.cn/news/detail-513404.html
到了這里,關(guān)于解決 Spring Cloud 2021.0.5 版本,使用 nacos 做配置中心,報(bào) No spring.config.import property has been defined 的問題的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!