1、導入依賴:pom.xml
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies>
2、配置文件:application.yml
server:
port: 8001
spring:
application:
name: euraka
eureka:
instance:
hostname: 127.0.0.1
client:
fetch-registry: false #是否從eureka中獲取信息
register-with-eureka: false #是否將自己註冊到eureka中
service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
3、啓動類:EurekaApplication
@SpringBootApplication
@EnableEurekaServer
public class EurekaApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaApplication.class, args);
}
}