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>
<!-- 解決啟動Param 'serviceName' is illegal, serviceName is blank問題 -->
<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)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
通過Feign進行調(diào)用@FeignClient?找不到的解決方案
這篇文章主要介紹了通過Feign進行調(diào)用@FeignClient?找不到的解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-03-03
Maven發(fā)布項目 (jar包) 到Nexus私服中的操作
這篇文章主要介紹了Maven發(fā)布項目 (jar包) 到Nexus私服中的操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-10-10
springboot各種格式轉(zhuǎn)pdf的實例代碼
這篇文章主要介紹了springboot各種格式轉(zhuǎn)pdf的實例代碼,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2021-01-01
SpringBoot中SmartLifecycle的使用解析
這篇文章主要介紹了SpringBoot中SmartLifecycle的使用解析,SmartLifecycle是一個擴展了Lifecycle接口,可以跟蹤spring容器ApplicationContext刷新或者關(guān)閉的接口,實現(xiàn)該接口的實現(xiàn)類有特定的執(zhí)行順序,需要的朋友可以參考下2023-11-11
利用Spring Boot創(chuàng)建docker image的完整步驟
這篇文章主要給大家介紹了關(guān)于如何利用Spring Boot創(chuàng)建docker image的完整步驟,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-08-08
JAVA簡單鏈接Oracle數(shù)據(jù)庫 注冊和登陸功能的實現(xiàn)代碼
這篇文章主要介紹了JAVA鏈接Oracle并實現(xiàn)注冊與登錄功能的代碼實例,有需要的朋友可以參考一下2014-01-01
SpringBoot中的@CacheEvict 注解的實現(xiàn)
本文主要介紹了SpringBoot中的@CacheEvict注解的實現(xiàn),@CacheEvict 注解用于清空緩存,文中通過示例代碼介紹的非常詳細,需要的朋友們下面隨著小編來一起學習學習吧2024-03-03
feignclient?https?接口調(diào)用報證書錯誤的解決方案
這篇文章主要介紹了feignclient?https?接口調(diào)用報證書錯誤的解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-03-03

