微服務系列之-Eureka Client集成

一.操作步驟

  1. 客戶端依賴
<dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
  1. 客戶端配置文件
server:
  port: 8081

spring:
  application:
    name: qyeurekaclient
  profiles:
    active: gr
eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/
  1. 啓動類
@Slf4j
@SpringBootApplication
@EnableDiscoveryClient
public class EurekaClientApplication
{
    public static void main( String[] args )
    {
        ApplicationContext context = SpringApplication.run(EurekaClientApplication.class, args);
        String serverPort = context.getEnvironment().getProperty("server.port");
        log.info("後臺管理服務客戶端啓動成功! Url: http://127.0.0.1:".concat(serverPort));
    }
}
  1. 界面展示
    在這裏插入圖片描述

經由上面幾個步驟可以很輕鬆的集成客戶端。

項目地址:微服務集成項目

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章