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的页面启动完成了