Spring Cloud Euerka 注册中心

注册中心相关代码

启动类

EurekaApplication相关代码如下

@SpringBootApplication
@EnableEurekaServer
public class EurekaApplication {
    public static void main(String[] args) {
        SpringApplication.run(EurekaApplication.class,args);
    }
}

单机application.yml相关配置项如下

#端口号修改为8000
server:
  port: 8000

#eureka实例,不注册自己
#所以 registerWithEureka=false
#不获取注册信息 fetchRegistry=false
eureka:
  instance:
    hostname: localhost
  client:
    registerWithEureka: false
    fetchRegistry: false
    serviceUrl:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

spring:
  application:
    name: eureka-server

此时启动服务
打开http://localhost:8000
eureka中无任何服务注册

相关代码如下https://github.com/15238822001/pa-life-cloud/tree/master/life-eureka

你可能感兴趣的:(Spring Cloud Euerka 注册中心)