1,建立一个作为注册中心的子项目 2,引入依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
3,在yml文件中的一些配置
server:
port: 7001
#Eureka
eureka:
instance:
hostname: localhost #Eureka服务端实例名称
client:
register-with-eureka: false #表示是否eureka注册中心注册自己
fetch-registry: false #如果为false则表示自己为注册中心
service-url: #监控页面
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
4,然后在一个作为服务的子项目中引入依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
<version>1.4.6.RELEASE</version>
</dependency>
5,yml配置:
#Eureka的配置,服务注册到哪里
eureka:
client:
service-url:
defaultZone: http://localhost:7001/eureka/
instance:
instance-id: springcloud-provider-dept8001 #修改eureka中的默认描述信息