一、添加依赖

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
这里使用的boot版本为2.2.2.RELEASE,cloud版本为Hoxton.SR1。
需要注意一下版本

官网地址:https://spring.io/projects/spring-cloud#overview
在启动类上加上注解@EnableEurekaServer
,表明该项目是Eureka Server
@SpringBootApplication
@EnableEurekaServer
public class EurekaApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaApplication.class, args);
}
}
然后修改yml文件
spring:
application:
name: eureka #服务名
server:
port: 1998 #eureka 默认端口为8761
eureka:
client:
register-with-eureka: false #是否注册到eureka上 默认为true 但是我这个是作为Eureka Server的,所以不需要注册
fetch-registry: false #是否从Eureka Server上获取注册信息

网友评论