springboot使用nacos的示例詳解
1、pom.xml:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.4.2</version> <relativePath/> </parent> <groupId>com.shif</groupId> <artifactId>spring-jwt</artifactId> <version>0.0.1-SNAPSHOT</version> <name>spring-jwt</name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> <nacos-config-spring-boot.version>0.2.1</nacos-config-spring-boot.version> </properties> <dependencies> <!-- 解決啟動(dòng)Param 'serviceName' is illegal, serviceName is blank問(wèn)題 --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-bootstrap</artifactId> <version>3.0.4</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt</artifactId> <version>0.9.0</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.59</version> </dependency> <!-- nacos discovery and config 版本選擇參考nacos官網(wǎng)推薦--> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> <version>2021.1</version> </dependency> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> <version>2021.1</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
版本選擇參考nacos官網(wǎng)推薦
2、application.yml和bootstrap.yml:
spring: profiles: active: dev redis: host: ${REDIS_HOST:20.20.30.125} port: ${REDIS_PORT:6379} password: ${REDIS_PASSWORD:abc@123}
server: address: x.x.x.x port: 9091 spring: application: name: jwttest cloud: nacos: discovery: server-addr: x.x.x.x:8848 config: server-addr: x.x.x.x:8848 group: dev file-extension: yaml
到此這篇關(guān)于springboot使用nacos的示例詳解的文章就介紹到這了,更多相關(guān)springboot使用nacos內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
通過(guò)Feign進(jìn)行調(diào)用@FeignClient?找不到的解決方案
這篇文章主要介紹了通過(guò)Feign進(jìn)行調(diào)用@FeignClient?找不到的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-03-03Maven發(fā)布項(xiàng)目 (jar包) 到Nexus私服中的操作
這篇文章主要介紹了Maven發(fā)布項(xiàng)目 (jar包) 到Nexus私服中的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-10-10springboot各種格式轉(zhuǎn)pdf的實(shí)例代碼
這篇文章主要介紹了springboot各種格式轉(zhuǎn)pdf的實(shí)例代碼,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-01-01SpringBoot中SmartLifecycle的使用解析
這篇文章主要介紹了SpringBoot中SmartLifecycle的使用解析,SmartLifecycle是一個(gè)擴(kuò)展了Lifecycle接口,可以跟蹤spring容器ApplicationContext刷新或者關(guān)閉的接口,實(shí)現(xiàn)該接口的實(shí)現(xiàn)類有特定的執(zhí)行順序,需要的朋友可以參考下2023-11-11利用Spring Boot創(chuàng)建docker image的完整步驟
這篇文章主要給大家介紹了關(guān)于如何利用Spring Boot創(chuàng)建docker image的完整步驟,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08JAVA簡(jiǎn)單鏈接Oracle數(shù)據(jù)庫(kù) 注冊(cè)和登陸功能的實(shí)現(xiàn)代碼
這篇文章主要介紹了JAVA鏈接Oracle并實(shí)現(xiàn)注冊(cè)與登錄功能的代碼實(shí)例,有需要的朋友可以參考一下2014-01-01SpringBoot中的@CacheEvict 注解的實(shí)現(xiàn)
本文主要介紹了SpringBoot中的@CacheEvict注解的實(shí)現(xiàn),@CacheEvict 注解用于清空緩存,文中通過(guò)示例代碼介紹的非常詳細(xì),需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2024-03-03feignclient?https?接口調(diào)用報(bào)證書(shū)錯(cuò)誤的解決方案
這篇文章主要介紹了feignclient?https?接口調(diào)用報(bào)證書(shū)錯(cuò)誤的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-03-03