添加依赖
// https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-eureka-server
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-server:4.0.0'
编写启动类,添加注解
@EnableEurekaServer
添加application.yaml文件,编写配置信息
server:
port:10086
spring:
application:
name: eurekaservice
eureka:
client:
service-url:
defaultZone:http://127.0.0.1:10086/eureka
服务注册
添加依赖
// https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-eureka-client
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client:4.1.0'
application.yaml配置
server:
port:10086
spring:
application:
name: userservice
eureka:
client:
service-url:
defaultZone:http://127.0.0.1:10086/eureka
注册发现: