启动:
mvn spring-boot:run
启动后,可以通过
http://localhost:8000/
进入管理界面,查看当前连接上来的微服务
pom中增加依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
启动类添加注解
@EnableEurekaServer
@EnableDiscoveryClient
下面的操作不是在这个项目(register-eureka)中做,而是在需要在eureka server中登记的微服务项目内做。
sample-service已经实现下面的这些步骤,启动后会自动登记在此项目创建的eureka server。
pom中增加依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
启动类添加注解
@EnableEurekaClient
application.yml添加配置
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8000/eureka #Eureka Server地址,可以写多个(逗号隔开)用于集群
instance:
preferIpAddress: true