1、新建maven项目,在pom.xml文件中配置eureka依赖,如下
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
2、在EurekaServiceApplication.class启动文件上添加@EnableEurekaServer注解
@SpringBootApplication
@EnableEurekaServer
public class EurekaServiceApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServiceApplication.class, args);
}
}
3、在application.yml文件中配置eureka地址
server:
port: 8673 #服务端口号
spring:
application:
name: eureka-service #服务名称
eureka:
client:
service-url:
defaultZone: http://127.0.0.1:8673/eureka/ #把自己注册到eureka