pom.xml檔案格式如下:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
建立application.yml檔案,加入如下内容。
server:
port: 8761
eureka:
client:
registerWithEureka: false
fetchRegistry: false
4.在src/main/java 下建立包com.helloworld.eureka
5.在com.helloworld.eureka包下建立類:
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
6.運作EurekaServer類,啟動完成後通路http://localhost:8761/,看到eureka server的頁面啟動完成了