以下為報錯信息:
No spring.config.import property has been defined
啟動時,控制臺已經(jīng)很明確的給出了一個標(biāo)準(zhǔn)的解決方案:
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.文章來源:http://www.zghlxwxcb.cn/news/detail-505892.html
經(jīng)過查閱官方資料,確認從2021.0.5版本起,Spring Cloud將不再默認啟用bootstrap 包,所以針對該問題,解決方案有兩種:文章來源地址http://www.zghlxwxcb.cn/news/detail-505892.html
- application.yml中添加以下配置,用以指定引入的配置文件。
spring:
config:
import: nacos:xxxx.yaml
- pom或build.gradle中引入boostrap依賴包:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
<version>4.0.1</version>
</dependency>
implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap:4.0.1'
到了這里,關(guān)于記錄一次SpringBoot3+Nacos Config做配置中心時,No spring.config.import property has been defined的問題的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!