1绪抛,如果idea沒有Spring Assistant插件沉迹,先下載插件file--->settings--->Plugins--->Spring Assistant安裝重啟idea
3,填寫自己項目的信息蛤育,我選擇使用的是maven
4,
5,然后在pom.xml文件里面加入依賴:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
4,修改啟動類瓦糕,添加Eureka Server的annotation,@EnableEurekaServer
5,在application.properties里面加入以下內(nèi)容
#端口號
server.port=8081
eureka.instance.hostname=localhost
#向注冊中心注冊服務(wù)
eureka.client.registerWithEureka=false
# 檢索服務(wù)
eureka.client.fetchRegistry=false
eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/
#在Eureka服務(wù)器獲取不到集群里對等服務(wù)器上的實例時咕娄,需要等待的時間
server.waitTimeInMsWhenSyncEmpty=0
#自我保護(hù)模式
server.enableSelfPreservation=false
5珊擂,啟動Eureka Server