添加pom依赖

<!-- Spring Cloud Alibaba Nacos-->
<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>

yml配置文件

spring:
  application:
    name: business-songzixian
  cloud:
    nacos:
      discovery:
        server-addr: http://localhost:8848

启动类添加@EnableDiscoveryClient注解

@EnableDiscoveryClient
@SpringBootApplication
public class XXXApplication {

    public static void main(String[] args) {
        SpringApplication.run(Oauth2BusinessApplication.class,args);
    }

}
Last modification:June 30, 2020
如果觉得这篇技术文章对你有用,请随意赞赏