1、創建maven項目,在pom.xml 中加入相應jar包
2、在src/main/resources中創建application.properties文件,內容爲
spring.application.name=eureka-server // 註冊中心服務名稱
server.port=8761 // 註冊中心服務端口
# 本身註冊中心是一個服務但是不需要註冊自己
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false // 本身註冊中心是一個服務但是不維護自己
3、在src/main/java 中創建啓動類
@EnableEurekaServer // 表示服務爲eureka服務
@SpringBootApplication
public class EurekaServerApplication
{
public static void main( String[] args )
{
SpringApplication.run(EurekaServerApplication.class, args);
}
}
4、啓動服務,在地址欄輸入localhost:8761 就可看到eureka的可視化界面表示成功,8761位自己定義的註冊中心端口