步骤:
- 导入pom文件
- 编写配置文件(port name defaultZone)
- 编写启动类(@EnableEurekaServer//开启eureka服务端的注解)
1导入pom文件
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
- 编写配置文件
server:
port: 8761
spring:
application:
name: eurekaServer
eureka:
server:
enable-self-preservation: false #关闭自我保护
eviction-interval-timer-in-ms: 5000
client:
register-with-eureka: true #该注册中心不像其它注册中心注册服务
fetch-registry: true #不从其它注册中心拉取服务 注意:默认开启集群,当部署单节点的时候,则将以上两项配置改为false
service-url:
defaultZone: http://localhost:8762/eureka
- 编写启动类
@SpringBootApplication
@EnableEurekaServer//开启eureka服务端的注解
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class);
}
}