這篇文章主要為大家展示了“Spring boot集成nacos配置中心的示例分析”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“Spring boot集成nacos配置中心的示例分析”這篇文章吧。
天水網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián),天水網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為天水上千提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站制作要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的天水做網(wǎng)站的公司定做!
<!-- spring boot --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.1.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <!-- nacos --> <dependency> <groupId>com.alibaba.boot</groupId> <artifactId>nacos-discovery-spring-boot-starter</artifactId> <version>0.2.7</version> </dependency>
nacos: discovery: server-addr: localhost:8848 spring: application: namex: easy-nacos2
@SpringBootApplication @EnableNacosDiscovery @EnableNacosConfig(globalProperties = @NacosProperties(serverAddr="127.0.0.1:8848")) // @NacosPropertySource(dataId = "easy-nacos_dev", groupId = "easy", autoRefreshed = true) // 數(shù)據(jù)ID,自動(dòng)刷新 public class NacosServiceDiscoveryApplication { public static void main(String[] args) { System.out.println("Hello World!"); SpringApplication.run(NacosServiceDiscoveryApplication.class, args); }
@Controller @RequestMapping("config") @NacosPropertySource(dataId = "easy-nacos_dev", groupId = "easy", autoRefreshed = true) // 數(shù)據(jù)ID,自動(dòng)刷新 public class ConfigController { // 如果寫 spring.application.namex 則讀取不到 // autoRefreshed 刷新 @NacosValue(value = "${namex:def}", autoRefreshed = true) private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } ....
以上是“Spring boot集成nacos配置中心的示例分析”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
本文題目:Springboot集成nacos配置中心的示例分析
文章分享:http://aaarwkj.com/article40/ipocho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站、手機(jī)網(wǎng)站建設(shè)、做網(wǎng)站、、云服務(wù)器、網(wǎng)站設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)