springboot加載不到nacos配置中心的配置問題處理
springboot加載不到nacos配置中心的配置
版本聲明-SpringBoot-2.5.12 Nacos-2.0.3
兩種可能
注: nacos引用的com.alibaba.cloud 而非springboot單應(yīng)用版
<!-- nacos:服務(wù)注冊 -->
<!-- https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-starter-alibaba-nacos-discovery -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>2021.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-starter-alibaba-nacos-config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>2021.1</version>
</dependency>Spring Boot 版本
Spring Boot 2.4版本開始,配置文件加載方式進(jìn)行了重構(gòu),重新引入
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-bootstrap -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
<version>3.1.1</version>
</dependency>Nacos 版本問題
Nacos2.0以后 有更新
在 Nacos Spring Cloud 中,dataId 的完整格式變更
${prefix}-${spring.profiles.active}.${file-extension} --> ${name}-${spring.profiles.active}.${file-extension}配置文件的名字對應(yīng)參數(shù)應(yīng)為:
spring.cloud.nacos.config.name=${spring.application.name}總結(jié)
以上為個人經(jīng)驗(yàn),希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
使用Filter實(shí)現(xiàn)登錄權(quán)限驗(yàn)證
這篇文章主要為大家詳細(xì)介紹了使用Filter實(shí)現(xiàn)登錄權(quán)限驗(yàn)證,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-10-10
關(guān)于springboot集成swagger3時spring-plugin-core報錯的問題
這篇文章主要介紹了關(guān)于springboot集成swagger3時spring-plugin-core報錯的問題,本文給大家分享解決方法,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2021-09-09
Java使用openOffice對于word的轉(zhuǎn)換及遇到的問題解決
開發(fā)過程中經(jīng)常會使用java將office系列文檔轉(zhuǎn)換為PDF, 一般都使用微軟提供的openoffice+jodconverter 實(shí)現(xiàn)轉(zhuǎn)換文檔,下面這篇文章主要給大家介紹了關(guān)于Java通過openOffice對于word的轉(zhuǎn)換及遇到問題的解決方法,需要的朋友可以參考下2018-09-09

