1、导入坐标
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<version>Greenwich.RELEASE</version>
</dependency>
2、启动类标注注解启用eurekaserver
@SpringBootApplication
//启用EurekaServer
@EnableEurekaServer
public class EurekaAPP {
public static void main(String[] args) {
SpringApplication.run(EurekaAPP.class,args);
}
}
3、配置文件
server:
port: 8761
eureka:
instance:
hostname: localhost #主机名
client:
service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka #eureka服务端地址,默认为http://localhost:8761/eureka
register-with-eureka: false #是否将自己的路径注册到eureka上,eureka server不需要,eureka provider client需要
fetch-registry: false #是否需要从eureka中抓取路径,eureka server不需要,eureka consumer client需要