SpringCloud------添加客户端Eureka Client

1.添加依赖

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

 

2.添加客户端配置

/src/main/java/resource/application.yml

server:
  port: 8770
eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/

spring:
application:
name: shop-gateway

 

3.添加启动类注解

@SpringBootApplication
@EnableDiscoveryClient
public class ShopGatewayApplication {

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

}

 

4.启动注册中心后,再启动客户端

访问地址

http://localhost:8761

如图:

 

posted @ 2020-02-25 15:39  玉天恒  阅读(472)  评论(0编辑  收藏  举报