标签:eureka
一、依赖 <dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<version>2.0.0.RC1</version>
</dependency>
二、启动类增加注解
@SpringBootApplication
@EnableEurekaServer
public class ServiceRegisterCenterDemoApplication {
public static void main(String[] args) {
SpringApplication.run(ServiceRegisterCenterDemoApplication.class, args);
}
}
三、单机注册中心配置
spring.application.name=service-register-center-demo
server.port=19001
eureka.instance.hostname=localhost
eureka.instance.app-group-name=test_group
eureka.instance.appname=register_center
eureka.instance.health-check-url-path=/health
eureka.instance.status-page-url-path=/status
eureka.client.enabled=true
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/
通过http://localhost:19001/ 可以访问到该服务的情况,图下:
通过http://localhost:19001/actuator 查看健康检查情况。
注意:
四、多个对等注册中心配置
instance 1
spring.application.name=service-register-center-demo
server.port=19001
eureka.instance.hostname=peer1
eureka.instance.app-group-name=test_group
eureka.instance.appname=register_center1
eureka.instance.health-check-url-path=/health
eureka.instance.status-page-url-path=/status
#eureka.client.enabled=true
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.client.serviceUrl.defaultZone=http://peer2:19001/eureka/
instance 2
spring.application.name=service-register-center-1-demo
server.port=19002
eureka.instance.hostname=peer2
eureka.instance.app-group-name=test_group
eureka.instance.appname=register_center2
eureka.instance.health-check-url-path=/health
eureka.instance.status-page-url-path=/status
#eureka.client.enabled=true
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.client.serviceUrl.defaultZone=http://peer1:19002/eureka/
注意:
五、配置参数说明
标签:eureka
原文地址:http://blog.51cto.com/881206524/2118250