application.yml
eureka:
instance:
hostname: localhost
client:
fetch-registry: false
register-with-eureka: false
# 以上兩條是否與其它Eureka服務器進行交互,實現互相註冊。默認值:true,開發環境下設置成:false
service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka
server:
enable-self-preservation: false #在開發環境可以禁用自我保護模式,但是在投入生產環境時需要將其啓用。
server:
port: 8761
在構建中使用Eureka starter依賴項,啓用Eureka服務器只需要做一件事。打開應用程序的主引導類並使用以下命令對其進行註釋@EnableEurekaServer:
@SpringBootApplication
@EnableEurekaServer
public class ServiceRegistryApplication {
public static void main(String[] args) {
SpringApplication.run(ServiceRegistryApplication.class, args);
}
}