注册微服务

pom

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

application.yml

server:
  port: 8001
spring:
  application:
    name: PROVIDER
eureka:
  client:
    # 表示是否将自己注册进入EurekaServer默认为true
    register-with-eureka: true
    # 是否从EurekaServer抓取已有的注册信息,默认为true
    # 单节点不会有影响,集群环境必须设置为true才能配合ribbon使用负载均衡
    fetch-registry: true
    # 注册到的EurekaServer路径
    service-url:
      defaultZone: http://localhost:7001/eureka


开启注解


@SpringBootApplication
@EnableEurekaClient
public class ProviderApplication {

    public static void main(String[] args) {
        SpringApplication.run(ProviderApplication.class, args);
    }

}
posted @ 2020-10-09 19:43  刃牙  阅读(108)  评论(0编辑  收藏  举报