1.版本控制
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
...
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR3</spring-cloud.version>
</properties>
2.添加@EnableEurekaServer
package cn.lovingliu.loving;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class LovingApplication {
public static void main(String[] args) {
SpringApplication.run(LovingApplication.class, args);
}
}
3.配置application.yml
eureka:
client:
fetch-registry: false # 该应用为注册中心 只用维护服务实例,无需检索服务
register-with-eureka: false # eureka 即是服务端又是服务端,且该应用是一个注册中心,所以取消向注册中心注册自己
service-url: # 地址
defaultZone: http://127.0.0.1:1000/eureka
server: #自我保护模式关闭 在注册中心会一直提示
enable-self-preservation: false
instance: #使用主机的IP地址来定义注册中心的地址
prefer-ip-address: true
spring:
application:
name: eureka
server:
port: 1000
网友评论