1. POM引入nacos依赖
1.1 添加nacos依赖
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-nacos-config</artifactId>
<version>2.1.0.RELEASE</version>
<type>jar.sha1</type>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>
1.2 删除eureka依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
1.4 添加exclusions,用于禁止依赖传递
<dependency>
<groupId>com.sgcc.dlsc</groupId>
<artifactId>px-trade-config-client</artifactId>
<version>0.0.1-RELEASE</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
1.5 启动类加上@EnableDiscoveryClient注解
1.6 修改配置文件,添加配置nacos服务地址
spring:
cloud:
# 使用 Naoos 作为服务注册发现
nacos:
discovery:
server-addr: 127.0.0.1:8848
1.7 清楚缓存和刷新依赖
1、刷新依赖
2、mvn install