创建一个eureka-server的模块
在pom中引入eureka
java
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<version>3.1.2</version>
</dependency>
在application.yml文件中配置Eureka
java
server:
port: 8079
eureka:
instance:
hostname: bowen-eureka
client:
register-with-eureka: false
fetch-registry: false
service-url:
defalutZone: http://${eureka.instance.hostname}:${server.port}/eureka/
创建 EurekaServerApplication 启动类
java
package com.lingyang;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
/**
* @author **文
* @Description:
* @createDate 2024/8/12 14:25
**/
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
public static void main(String[] args){
SpringApplication.run(EurekaServerApplication.class);
}
}
最后我被坑了,eureka不维护了。我用jdk17搞。操蛋了。解决不了