1.依赖
<dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> </dependency>
2.配置文件
server.port=9001 spring.application.name=userservices spring.cloud.nacos.server-addr=127.0.0.1:8848 spring.cloud.nacos.discovery.server-addr=${spring.cloud.nacos.server-addr}
3.启动
package org.thj; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; @SpringBootApplication @EnableDiscoveryClient public class UserservicesApplication { public static void main(String[] args) { SpringApplication.run(UserservicesApplication.class, args); } }