将微服务注册到Euraka

1、添加依赖

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>

2、配置文件

eureka:
  client:
    registerWithEureka: true 
    fetchRegistry: true
    serviceUrl: 
      defaultZone: ${eureka_host:http://eureka1:50101/eureka/} 
  instance:
    prefer-ip-adress: true #将自己的ip注册到Eureka管理
    ip-address: ${ip:127.0.0.1}
    instantce-id: ${spring.application.name}:${server.port} #指定实例id

3、启动类注解

@EnableDiscoveryClient //表示这是一个Eureka客户端
原文地址:https://www.cnblogs.com/dehigher/p/10133609.html