SpringCloud核心教程 | 第三篇:服務註冊與發現 Eureka篇

weixin_30924079發表於2020-04-04

Spring Cloud簡介

Spring Cloud是一個基於Spring Boot實現的雲應用開發工具,它為基於JVM的雲應用開發中涉及的配置管理、服務發現、斷路器、智慧路由、微代理、控制匯流排、全域性鎖、決策競選、分散式會話和叢集狀態管理等操作提供了一種簡單的開發方式。

Spring Cloud包含了多個子專案(針對分散式系統中涉及的多個不同開源產品),比如:Spring Cloud ConfigSpring Cloud NetflixSpring Cloud CloudFoundrySpring Cloud AWSSpring Cloud SecuritySpring Cloud CommonsSpring Cloud ZookeeperSpring Cloud CLI等專案。

微服務架構

“微服務架構”在這幾年非常的火熱,以至於關於微服務架構相關的開源產品被反覆的提及(比如: netflixdubbo),Spring Cloud也因Spring社群的強大知名度和影響力也被廣大架構師與開發者備受關注。

那麼什麼是“微服務架構”呢?簡單的說,微服務架構就是將一個完整的應用從資料儲存開始垂直拆分成多個不同的服務,每個服務都能獨立部署、獨立維護、獨立擴充套件,服務與服務間通過諸如RESTful API的方式互相呼叫。

對於“微服務架構”,大家在網際網路可以搜尋到很多相關的介紹和研究文章來進行學習和了解。也可以閱讀始祖Martin Fowler的《Microservices》(中文版翻譯點選檢視),本文不做更多的介紹和描述。

服務治理

在簡單介紹了Spring Cloud和微服務架構之後,下面迴歸本文的主旨內容,如何使用Spring Cloud來實現服務治理。

由於Spring Cloud為服務治理做了一層抽象介面,所以在Spring Cloud應用中可以支援多種不同的服務治理框架,比如:Netflix EurekaConsulZookeeper。在Spring Cloud服務治理抽象層的作用下,我們可以無縫地切換服務治理實現,並且不影響任何其他的服務註冊、服務發現、服務呼叫等邏輯。

所以,下面我們通過Eureka這種種服務治理的實現來體會Spring Cloud這一層抽象所帶來的好處。
下一篇介紹基於Consul的服務註冊與呼叫。

Spring Cloud Eureka

首先,我們來嘗試使用Spring Cloud Eureka來實現服務治理。

Spring Cloud EurekaSpring Cloud Netflix專案下的服務治理模組。而Spring Cloud Netflix專案是Spring Cloud的子專案之一,主要內容是對Netflix公司一系列開源產品的包裝,它為Spring Boot應用提供了自配置的Netflix OSS整合。通過一些簡單的註解,開發者就可以快速的在應用中配置一下常用模組並構建龐大的分散式系統。它主要提供的模組包括:服務發現(Eureka),斷路器(Hystrix),智慧路由(Zuul),客戶端負載均衡(Ribbon)等。

下面,就來具體看看如何使用Spring Cloud Eureka實現服務治理,這裡使用eureka-server為服務註冊中心工程、eureka-provider服務提供者工程、eureka-consumer服務消費者工程。

準備工作

環境:

windows
jdk 8
maven 3.0
IDEA

構建工程

首先構建父工程,引入父工程依賴:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    
    <parent>
        <groupId>cn.zhangbox</groupId>
        <artifactId>spring-cloud-study</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    
    <groupId>cn.zhangbox</groupId>
    <artifactId>spring-cloud-eureka</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    
    <!--子模組-->
    <modules>
        <module>eureka-server</module>
        <module>eureka-provider</module>
        <module>eureka-consumer</module>
    </modules>
    
</project>

父工程取名為:spring-cloud-eureka
構建子工程,分別建立工程名為:eureka-servereureka-providereureka-consumer並在pom中加入以下依賴:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>cn.zhangbox</groupId>
        <artifactId>spring-cloud-eureka</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <groupId>cn.zhangbox</groupId>
    <artifactId>eureka-server</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>

    <name>eureka-server</name>
    <description>Spring Cloud In Action</description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <!-- 引入eureka服務端依賴start -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka-server</artifactId>
        </dependency>
        <!-- 引入eureka服務端依賴end -->
    </dependencies>

    <!-- 新增cloud 依賴start -->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Dalston.SR1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <!-- 新增cloud 依賴end -->

    <!-- 新增maven構建外掛start -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
    <!-- 新增maven構建外掛end -->

</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>cn.zhangbox</groupId>
        <artifactId>spring-cloud-eureka</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <groupId>cn.zhangbox</groupId>
    <artifactId>eureka-provider</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>eureka-provider</name>
    <description>this project for Spring Boot</description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <!-- 版本控制 -->
        <commons-lang3.version>3.4</commons-lang3.version>
        <commons-codec.version>1.10</commons-codec.version>
        <mybatis-spring-boot.version>1.2.0</mybatis-spring-boot.version>
        <lombok.version>1.16.14</lombok.version>
        <fastjson.version>1.2.41</fastjson.version>
        <druid.version>1.1.2</druid.version>
    </properties>

    <repositories>
        <!-- 阿里私服 -->
        <repository>
            <id>aliyunmaven</id>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        </repository>
    </repositories>

    <dependencies>

        <!-- mybatis核心包 start -->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>${mybatis-spring-boot.version}</version>
        </dependency>
        <!-- mybatis核心包 end -->

        <!-- 新增eureka支援start -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        <!-- 新增eureka支援start -->

        <!-- SpringWEB核心包 start -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- SpringWEB核心包 end -->

        <!-- Swagger核心包 start -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.6.1</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.6.1</version>
        </dependency>
        <!-- Swagger核心包 end -->

        <!-- mysql驅動核心包 start -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <!-- mysql驅動核心包 end -->

        <!-- sprigTest核心包 start -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- sprigTest核心包 end -->

        <!-- commons工具核心包 start -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${commons-lang3.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>${commons-codec.version}</version>
        </dependency>
        <!-- commons工具核心包 end -->

        <!-- fastjson核心包 start -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>${fastjson.version}</version>
        </dependency>
        <!-- fastjson核心包 end -->

        <!-- druid核心包 start -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>${druid.version}</version>
        </dependency>
        <!-- druid核心包 end -->

        <!-- lombok核心包 start -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
        </dependency>
        <!-- lombok核心包 end -->
    </dependencies>

    <!-- 新增cloud 依賴start -->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Dalston.SR1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <!-- 新增cloud 依賴end -->

    <build>
        <finalName>eureka-provider</finalName>
        <plugins>
            <!-- 新增maven構建外掛start -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <!-- 新增maven構建外掛end -->
        </plugins>
    </build>

</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>cn.zhangbox</groupId>
        <artifactId>spring-cloud-eureka</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <groupId>cn.zhangbox</groupId>
    <artifactId>eureka-consumer</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>eureka-consumer</name>
    <description>this project for Spring Boot</description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <!-- 版本控制 -->
        <commons-lang3.version>3.4</commons-lang3.version>
        <commons-codec.version>1.10</commons-codec.version>
        <mybatis-spring-boot.version>1.2.0</mybatis-spring-boot.version>
        <lombok.version>1.16.14</lombok.version>
        <fastjson.version>1.2.41</fastjson.version>
        <druid.version>1.1.2</druid.version>
    </properties>

    <repositories>
        <!-- 阿里私服 -->
        <repository>
            <id>aliyunmaven</id>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        </repository>
    </repositories>

    <dependencies>
        <!-- 新增eureka支援start -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        <!-- 新增eureka支援start -->

        <!-- 新增feign支援start -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-feign</artifactId>
        </dependency>
        <!-- 新增feign支援end -->

        <!-- SpringWEB核心包 start -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- SpringWEB核心包 end -->

        <!-- Swagger核心包 start -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.6.1</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.6.1</version>
        </dependency>
        <!-- Swagger核心包 end -->

        <!-- sprigTest核心包 start -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- sprigTest核心包 end -->

        <!-- commons工具核心包 start -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${commons-lang3.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>${commons-codec.version}</version>
        </dependency>
        <!-- commons工具核心包 end -->

        <!-- fastjson核心包 start -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>${fastjson.version}</version>
        </dependency>
        <!-- fastjson核心包 end -->

        <!-- lombok核心包 start -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
        </dependency>
        <!-- lombok核心包 end -->
    </dependencies>

    <!-- 新增cloud 依賴start -->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Dalston.SR1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <!-- 新增cloud 依賴end -->

    <build>
        <finalName>eureka-provider</finalName>
        <plugins>
            <!-- 新增maven構建外掛start -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <!-- 新增maven構建外掛end -->
        </plugins>
    </build>

</project>

工程構建完成。

服務註冊中心工程配置

首先:eureka-server工程下resource目錄下新增application.yml檔案並加入以下配置:

#工程名稱
spring:
  application:
    name: eureka-server
#選擇哪一個環境的配置
#這裡可以在每個環境配置redis,資料庫(mysql),訊息(kafka)等相關的元件的配置
  profiles:
    active: dev
#配置eureka註冊中心
eureka:
  #server:
    #配置關閉自我保護模式
    #enableSelfPreservation: false
    #配置Eureka Server清理無效節點的時間間隔
    #eviction-interval-timer-in-ms: 4000
  instance:
    #配置與此例項相關聯的主機名,是其他例項可以用來進行請求的準確名稱
    hostname: eureka-server
    #顯示服務ip地址
    preferIpAddress: true
    #獲取服務的ip和埠
    instanceId: ${spring.cloud.client.ipAddress}:${server.port}
  client:
    #配置不將自己註冊到eureka註冊中心
    register-with-eureka: false
    #配置此客戶端不獲取eureka伺服器登錄檔上的註冊資訊
    fetch-registry: false
    serviceUrl:
          #配置預設節點有資訊,這裡是獲取本機的ip和埠來實現,如果不配置,預設會找8761埠,這裡配置的是1001埠,因此會報錯
          defaultZone: http://${spring.cloud.client.ipAddress}:${server.port}/eureka/
      
#文件塊區分為三個---
---
server:
  port: 1001
spring:
  profiles: dev
#日誌
logging:
  config: classpath:log/logback.xml
  path: log/eureka-server

#文件塊區分為三個---
---
server:
  port: 1002
spring:
  profiles: test
#日誌
logging:
  config: classpath:log/logback.xml
  path: usr/eureka-server/log/eureka-server

#文件塊區分為三個---
---
server:
  port: 1003
spring:
  profiles: prod
#日誌
logging:
  config: classpath:log/logback.xml
  path: usr/eureka-server/log/eureka-server

這裡日誌的配置不在詳細說明,不知道怎麼配置可以參考這篇文章:
SpringBoot進階教程 | 第二篇:日誌元件logback實現日誌分級列印

其次:建立核心啟動類:

@EnableEurekaServer//加上此註解表示將此工程啟動後為註冊中心
@SpringBootApplication
public class EurekaServerApplication {

    public static void main(String[] args) {
        new SpringApplicationBuilder(EurekaServerApplication.class).web(true).run(args);
    }

}

最後:啟動專案,看到如下日誌列印資訊:

 .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.3.RELEASE)

2018-07-17 15:05:53.541  INFO 7080 --- [           main] c.z.eureka.EurekaServerApplication       : The following profiles are active: dev
2018-07-17 15:05:53.588  INFO 7080 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5b22b970: startup date [Tue Jul 17 15:05:53 GMT+08:00 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@3af0a9da
2018-07-17 15:05:55.126  INFO 7080 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=cd854175-7c7f-3c0f-8597-c3d23f037104
2018-07-17 15:05:55.147  INFO 7080 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-07-17 15:05:55.247  INFO 7080 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.netflix.metrics.MetricsInterceptorConfiguration$MetricsRestTemplateConfiguration' of type [org.springframework.cloud.netflix.metrics.MetricsInterceptorConfiguration$MetricsRestTemplateConfiguration$$EnhancerBySpringCGLIB$$a90c774] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-17 15:05:55.259  INFO 7080 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$f47e2430] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-17 15:05:55.658  INFO 7080 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 1001 (http)
2018-07-17 15:05:55.670  INFO 7080 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2018-07-17 15:05:55.672  INFO 7080 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.14
2018-07-17 15:05:55.946  INFO 7080 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-07-17 15:05:55.947  INFO 7080 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2359 ms
2018-07-17 15:05:57.669  INFO 7080 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'metricsFilter' to: [/*]
2018-07-17 15:05:57.680  INFO 7080 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-07-17 15:05:57.681  INFO 7080 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-07-17 15:05:57.681  INFO 7080 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-07-17 15:05:57.681  INFO 7080 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-07-17 15:05:57.682  INFO 7080 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'webRequestTraceFilter' to: [/*]
2018-07-17 15:05:57.683  INFO 7080 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'servletContainer' to urls: [/eureka/*]
2018-07-17 15:05:57.683  INFO 7080 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'applicationContextIdFilter' to: [/*]
2018-07-17 15:05:57.683  INFO 7080 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2018-07-17 15:05:58.056  INFO 7080 --- [ost-startStop-1] c.s.j.s.i.a.WebApplicationImpl           : Initiating Jersey application, version 'Jersey: 1.19.1 03/11/2016 02:08 PM'
2018-07-17 15:05:58.376  INFO 7080 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2018-07-17 15:05:58.378  INFO 7080 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2018-07-17 15:05:58.617  INFO 7080 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2018-07-17 15:05:58.618  INFO 7080 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2018-07-17 15:06:00.945  INFO 7080 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5b22b970: startup date [Tue Jul 17 15:05:53 GMT+08:00 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@3af0a9da
2018-07-17 15:06:02.200  INFO 7080 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-07-17 15:06:02.202  INFO 7080 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-07-17 15:06:02.209  INFO 7080 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/],methods=[GET]}" onto public java.lang.String org.springframework.cloud.netflix.eureka.server.EurekaController.status(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.Object>)
2018-07-17 15:06:02.209  INFO 7080 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/lastn],methods=[GET]}" onto public java.lang.String org.springframework.cloud.netflix.eureka.server.EurekaController.lastn(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.Object>)
2018-07-17 15:06:02.257  INFO 7080 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-17 15:06:02.258  INFO 7080 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-17 15:06:02.590  INFO 7080 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-17 15:06:04.453  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/logfile || /logfile.json],methods=[GET || HEAD]}" onto public void org.springframework.boot.actuate.endpoint.mvc.LogFileMvcEndpoint.invoke(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws javax.servlet.ServletException,java.io.IOException
2018-07-17 15:06:04.454  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/archaius || /archaius.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-07-17 15:06:04.456  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/health || /health.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke(javax.servlet.http.HttpServletRequest,java.security.Principal)
2018-07-17 15:06:04.457  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/auditevents || /auditevents.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public org.springframework.http.ResponseEntity<?> org.springframework.boot.actuate.endpoint.mvc.AuditEventsMvcEndpoint.findByPrincipalAndAfterAndType(java.lang.String,java.util.Date,java.lang.String)
2018-07-17 15:06:04.458  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/beans || /beans.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-07-17 15:06:04.460  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/pause || /pause.json],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.endpoint.GenericPostableMvcEndpoint.invoke()
2018-07-17 15:06:04.461  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/service-registry/instance-status],methods=[GET]}" onto public org.springframework.http.ResponseEntity org.springframework.cloud.client.serviceregistry.endpoint.ServiceRegistryEndpoint.getStatus()
2018-07-17 15:06:04.461  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/service-registry/instance-status],methods=[POST]}" onto public org.springframework.http.ResponseEntity<?> org.springframework.cloud.client.serviceregistry.endpoint.ServiceRegistryEndpoint.setStatus(java.lang.String)
2018-07-17 15:06:04.462  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/autoconfig || /autoconfig.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-07-17 15:06:04.463  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/metrics/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint.value(java.lang.String)
2018-07-17 15:06:04.463  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/metrics || /metrics.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-07-17 15:06:04.466  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/info || /info.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-07-17 15:06:04.468  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/loggers/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.LoggersMvcEndpoint.get(java.lang.String)
2018-07-17 15:06:04.468  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/loggers/{name:.*}],methods=[POST],consumes=[application/vnd.spring-boot.actuator.v1+json || application/json],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.LoggersMvcEndpoint.set(java.lang.String,java.util.Map<java.lang.String, java.lang.String>)
2018-07-17 15:06:04.468  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/loggers || /loggers.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-07-17 15:06:04.469  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/resume || /resume.json],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.endpoint.GenericPostableMvcEndpoint.invoke()
2018-07-17 15:06:04.471  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/dump || /dump.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-07-17 15:06:04.472  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/env],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.context.environment.EnvironmentManagerMvcEndpoint.value(java.util.Map<java.lang.String, java.lang.String>)
2018-07-17 15:06:04.473  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/env/reset],methods=[POST]}" onto public java.util.Map<java.lang.String, java.lang.Object> org.springframework.cloud.context.environment.EnvironmentManagerMvcEndpoint.reset()
2018-07-17 15:06:04.473  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/mappings || /mappings.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-07-17 15:06:04.474  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/features || /features.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-07-17 15:06:04.474  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/trace || /trace.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-07-17 15:06:04.475  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/env/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint.value(java.lang.String)
2018-07-17 15:06:04.476  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/env || /env.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-07-17 15:06:04.478  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/restart || /restart.json],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.context.restart.RestartMvcEndpoint.invoke()
2018-07-17 15:06:04.479  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/heapdump || /heapdump.json],methods=[GET],produces=[application/octet-stream]}" onto public void org.springframework.boot.actuate.endpoint.mvc.HeapdumpMvcEndpoint.invoke(boolean,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.io.IOException,javax.servlet.ServletException
2018-07-17 15:06:04.480  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/configprops || /configprops.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-07-17 15:06:04.480  INFO 7080 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/refresh || /refresh.json],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.endpoint.GenericPostableMvcEndpoint.invoke()
2018-07-17 15:06:04.762  INFO 7080 --- [           main] o.s.ui.freemarker.SpringTemplateLoader   : SpringTemplateLoader for FreeMarker: using resource loader [org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5b22b970: startup date [Tue Jul 17 15:05:53 GMT+08:00 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@3af0a9da] and template loader path [classpath:/templates/]
2018-07-17 15:06:04.763  INFO 7080 --- [           main] o.s.w.s.v.f.FreeMarkerConfigurer         : ClassTemplateLoader for Spring macros added to FreeMarker configuration
2018-07-17 15:06:06.416  WARN 7080 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2018-07-17 15:06:06.440  INFO 7080 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2018-07-17 15:06:06.871  WARN 7080 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2018-07-17 15:06:06.872  INFO 7080 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2018-07-17 15:06:07.545  INFO 7080 --- [           main] o.s.c.n.eureka.InstanceInfoFactory       : Setting initial instance status as: STARTING
2018-07-17 15:06:07.746  INFO 7080 --- [           main] com.netflix.discovery.DiscoveryClient    : Initializing Eureka in region us-east-1
2018-07-17 15:06:07.746  INFO 7080 --- [           main] com.netflix.discovery.DiscoveryClient    : Client configured to neither register nor query for data.
2018-07-17 15:06:07.996  INFO 7080 --- [           main] com.netflix.discovery.DiscoveryClient    : Discovery Client initialized at timestamp 1531811167765 with initial instances count: 0
2018-07-17 15:06:08.140  INFO 7080 --- [           main] c.n.eureka.DefaultEurekaServerContext    : Initializing ...
2018-07-17 15:06:08.143  WARN 7080 --- [           main] c.n.eureka.cluster.PeerEurekaNodes       : The replica size seems to be empty. Check the route 53 DNS Registry
2018-07-17 15:06:08.159  INFO 7080 --- [           main] c.n.e.registry.AbstractInstanceRegistry  : Finished initializing remote region registries. All known remote regions: []
2018-07-17 15:06:08.159  INFO 7080 --- [           main] c.n.eureka.DefaultEurekaServerContext    : Initialized
2018-07-17 15:06:08.443  INFO 7080 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-07-17 15:06:08.458  INFO 7080 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'environmentManager' has been autodetected for JMX exposure
2018-07-17 15:06:08.461  INFO 7080 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'configurationPropertiesRebinder' has been autodetected for JMX exposure
2018-07-17 15:06:08.462  INFO 7080 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'refreshEndpoint' has been autodetected for JMX exposure
2018-07-17 15:06:08.463  INFO 7080 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'restartEndpoint' has been autodetected for JMX exposure
2018-07-17 15:06:08.464  INFO 7080 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'serviceRegistryEndpoint' has been autodetected for JMX exposure
2018-07-17 15:06:08.465  INFO 7080 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'refreshScope' has been autodetected for JMX exposure
2018-07-17 15:06:08.468  INFO 7080 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'environmentManager': registering with JMX server as MBean [org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager]
2018-07-17 15:06:08.492  INFO 7080 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'restartEndpoint': registering with JMX server as MBean [org.springframework.cloud.context.restart:name=restartEndpoint,type=RestartEndpoint]
2018-07-17 15:06:08.574  INFO 7080 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'serviceRegistryEndpoint': registering with JMX server as MBean [org.springframework.cloud.client.serviceregistry.endpoint:name=serviceRegistryEndpoint,type=ServiceRegistryEndpoint]
2018-07-17 15:06:08.586  INFO 7080 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'refreshScope': registering with JMX server as MBean [org.springframework.cloud.context.scope.refresh:name=refreshScope,type=RefreshScope]
2018-07-17 15:06:08.603  INFO 7080 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'configurationPropertiesRebinder': registering with JMX server as MBean [org.springframework.cloud.context.properties:name=configurationPropertiesRebinder,context=5b22b970,type=ConfigurationPropertiesRebinder]
2018-07-17 15:06:08.608  INFO 7080 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'refreshEndpoint': registering with JMX server as MBean [org.springframework.cloud.endpoint:name=refreshEndpoint,type=RefreshEndpoint]
2018-07-17 15:06:08.609  INFO 7080 --- [           main] o.s.b.a.e.jmx.EndpointMBeanExporter      : Registering beans for JMX exposure on startup
2018-07-17 15:06:08.979  INFO 7080 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
2018-07-17 15:06:08.980  INFO 7080 --- [           main] o.s.c.n.e.s.EurekaServiceRegistry        : Registering application eureka-server with eureka with status UP
2018-07-17 15:06:08.983  INFO 7080 --- [           main] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'auditEventsEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=auditEventsEndpoint]
2018-07-17 15:06:08.991  INFO 7080 --- [           main] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'featuresEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=featuresEndpoint]
2018-07-17 15:06:08.998  INFO 7080 --- [           main] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'requestMappingEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=requestMappingEndpoint]
2018-07-17 15:06:09.000  INFO 7080 --- [           main] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'environmentEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=environmentEndpoint]
2018-07-17 15:06:09.002  INFO 7080 --- [           main] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'healthEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=healthEndpoint]
2018-07-17 15:06:09.005  INFO 7080 --- [           main] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'beansEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=beansEndpoint]
2018-07-17 15:06:09.007  INFO 7080 --- [           main] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'infoEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=infoEndpoint]
2018-07-17 15:06:09.010  INFO 7080 --- [           main] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'loggersEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=loggersEndpoint]
2018-07-17 15:06:09.017  INFO 7080 --- [           main] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'metricsEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=metricsEndpoint]
2018-07-17 15:06:09.019  INFO 7080 --- [           main] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'traceEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=traceEndpoint]
2018-07-17 15:06:09.021  INFO 7080 --- [           main] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'dumpEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=dumpEndpoint]
2018-07-17 15:06:09.023  INFO 7080 --- [           main] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'autoConfigurationReportEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=autoConfigurationReportEndpoint]
2018-07-17 15:06:09.026  INFO 7080 --- [           main] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'configurationPropertiesReportEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=configurationPropertiesReportEndpoint]
2018-07-17 15:06:09.028  INFO 7080 --- [           main] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'archaiusEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=archaiusEndpoint]
2018-07-17 15:06:09.039  INFO 7080 --- [      Thread-42] o.s.c.n.e.server.EurekaServerBootstrap   : Setting the eureka configuration..
2018-07-17 15:06:09.040  INFO 7080 --- [      Thread-42] o.s.c.n.e.server.EurekaServerBootstrap   : Eureka data center value eureka.datacenter is not set, defaulting to default
2018-07-17 15:06:09.040  INFO 7080 --- [      Thread-42] o.s.c.n.e.server.EurekaServerBootstrap   : Eureka environment value eureka.environment is not set, defaulting to test
2018-07-17 15:06:09.109  INFO 7080 --- [      Thread-42] o.s.c.n.e.server.EurekaServerBootstrap   : isAws returned false
2018-07-17 15:06:09.111  INFO 7080 --- [      Thread-42] o.s.c.n.e.server.EurekaServerBootstrap   : Initialized server context
2018-07-17 15:06:09.111  INFO 7080 --- [      Thread-42] c.n.e.r.PeerAwareInstanceRegistryImpl    : Got 1 instances from neighboring DS node
2018-07-17 15:06:09.111  INFO 7080 --- [      Thread-42] c.n.e.r.PeerAwareInstanceRegistryImpl    : Renew threshold is: 1
2018-07-17 15:06:09.111  INFO 7080 --- [      Thread-42] c.n.e.r.PeerAwareInstanceRegistryImpl    : Changing status to UP
2018-07-17 15:06:09.118  INFO 7080 --- [      Thread-42] e.s.EurekaServerInitializerConfiguration : Started Eureka Server
2018-07-17 15:06:09.181  INFO 7080 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 1001 (http)
2018-07-17 15:06:09.183  INFO 7080 --- [           main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 1001
2018-07-17 15:06:09.189  INFO 7080 --- [           main] c.z.eureka.EurekaServerApplication       : Started EurekaServerApplication in 17.898 seconds (JVM running for 21.087)
2018-07-17 15:06:13.112  INFO 7080 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 0ms
2018-07-17 15:06:17.112  INFO 7080 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 0ms
2018-07-17 15:06:21.173  INFO 7080 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 61ms
2018-07-17 15:06:21.385  INFO 7080 --- [nio-1001-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2018-07-17 15:06:21.386  INFO 7080 --- [nio-1001-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2018-07-17 15:06:21.435  INFO 7080 --- [nio-1001-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 49 ms
2018-07-17 15:06:22.438  WARN 7080 --- [nio-1001-exec-2] c.n.e.registry.AbstractInstanceRegistry  : DS: Registry: lease doesn't exist, registering resource: EUREKA-PROVIDER - 10.25.26.144:8080
2018-07-17 15:06:22.439  WARN 7080 --- [nio-1001-exec-2] c.n.eureka.resources.InstanceResource    : Not Found (Renew): EUREKA-PROVIDER - 10.25.26.144:8080
2018-07-17 15:06:22.564  INFO 7080 --- [nio-1001-exec-3] c.n.e.registry.AbstractInstanceRegistry  : Registered instance EUREKA-PROVIDER/10.25.26.144:8080 with status UP (replication=false)
2018-07-17 15:06:25.173  INFO 7080 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 0ms
2018-07-17 15:06:29.173  INFO 7080 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 0ms
2018-07-17 15:06:31.169  WARN 7080 --- [nio-1001-exec-4] c.n.e.registry.AbstractInstanceRegistry  : DS: Registry: lease doesn't exist, registering resource: UNKNOWN - 10.25.26.144:8081
2018-07-17 15:06:31.169  WARN 7080 --- [nio-1001-exec-4] c.n.eureka.resources.InstanceResource    : Not Found (Renew): UNKNOWN - 10.25.26.144:8081
2018-07-17 15:06:31.198  INFO 7080 --- [nio-1001-exec-6] c.n.e.registry.AbstractInstanceRegistry  : Registered instance UNKNOWN/10.25.26.144:8081 with status UP (replication=false)

至此eureka註冊中心建立完成,瀏覽器輸入地址:http://localhost:1001/
可以看到如下頁面,表示服務啟動OK

圖片.png


這裡這看到還沒有服務暴露出來,是因為還沒建立服務提供者工程。

 

服務提供者工程配置

這裡服務提供者是使用之前SpringBoot進階教程 | 第三篇:整合Druid連線池以及Druid監控改造而來,這裡一樣的部分就不再重複說明,下面將說明新增的部分。
首先:修改application.yml配置為如下:

#公共配置
server:
    port: 80
    tomcat:
      uri-encoding: UTF-8
spring:
  application:
      #服務名稱,更關鍵,使用feign進行服務消費將以此為依據
      name: eureka-provider
  #啟用哪一個環境的配置檔案
  profiles:
    active: dev
  #連線池配置
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    # 使用druid資料來源
    type: com.alibaba.druid.pool.DruidDataSource
    druid:
      # 配置測試查詢語句
      validationQuery: SELECT 1 FROM DUAL
      # 初始化大小,最小,最大
      initialSize: 10
      minIdle: 10
      maxActive: 200
      # 配置一個連線在池中最小生存的時間,單位是毫秒
      minEvictableIdleTimeMillis: 180000
      testOnBorrow: false
      testWhileIdle: true
      removeAbandoned: true
      removeAbandonedTimeout: 1800
      logAbandoned: true
      # 開啟PSCache,並且指定每個連線上PSCache的大小
      poolPreparedStatements: true
      maxOpenPreparedStatements: 100
      # 配置監控統計攔截的filters,去掉後監控介面sql無法統計,'wall'用於防火牆
      filters: stat,wall,log4j
      # 通過connectProperties屬性來開啟mergeSql功能;慢SQL記錄
      connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000

#配置eureka獲取服務地址,這裡使用的是本地註冊中心
eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:1001/eureka/
  #配置Swagger相關資訊
  instance:
      prefer-ip-address: true
      instanceId: ${spring.cloud.client.ipAddress}:${server.port}
      status-page-url: http://${spring.cloud.client.ipAddress}:${server.port}/swagger-ui.html # ${server.port}為該服務的埠號

#mybatis
mybatis:
  # 實體類掃描
  type-aliases-package: cn.zhangbox.springboot.entity
  # 配置對映檔案位置
  mapper-locations: classpath:mapper/*.xml
  # 開啟駝峰匹配
  mapUnderscoreToCamelCase: true

---
#開發環境配置
server:
  #埠
  port: 8080
spring:
  profiles: dev
  # 資料來源配置
  datasource:
    url: jdbc:mysql://101.132.66.175:3306/student?useUnicode=true&characterEncoding=utf8&useSSL=false&tinyInt1isBit=true
    username: root
    password: 123456
#日誌
logging:
  config: classpath:log/logback.xml
  path: log/eureka-provider

---
#測試環境配置
server:
  #埠
  port: 80
spring:
  profiles: test
  # 資料來源配置
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/eureka-provider?useUnicode=true&characterEncoding=utf8&useSSL=false&tinyInt1isBit=true
    username: root
    password: 123456
#日誌
logging:
  config: classpath:log/logback.xml
  path: /home/log/eureka-provider

---
#生產環境配置
server:
  #埠
  port: 8080
spring:
  profiles: prod
  # 資料來源配置
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/eureka-provider?useUnicode=true&characterEncoding=utf8&useSSL=false&tinyInt1isBit=true
    username: root
    password: 123456
#日誌
logging:
  config: classpath:log/logback.xml
  path: /home/log/eureka-provider

其次:config目錄下增加SwaggerConfig類加入以下程式碼:

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket userApi() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.zhangbox.eureka.provider.controller"))//過濾的介面,有這掃描才會看到介面資訊
                .paths(PathSelectors.any())
                .build();
        return docket;
    }


    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("eureka服務端提供者介面平臺").description("服務相關資料介面")
                .termsOfServiceUrl("http://www.zhang.box.cn/").contact("技術開發部")
                .license("Licence Version 1.0").licenseUrl("#").version("1.0").build();
    }

}

這裡如果不會使用swagger的整合可以參考這篇文章:
SpringBoot非官方教程 | 第十一篇:SpringBoot整合swagger2,構建優雅的Restful API

接著:建立核心啟動類:

@EnableDiscoveryClient //使用該註解將註冊服務到eureka
@SpringBootApplication
@MapperScan("cn.zhangbox.eureka.provider.dao")//配置mybatis介面包掃描
public class EurekaProviderApplication extends SpringBootServletInitializer {

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

最後:啟動專案,看到如下日誌列印資訊:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.3.RELEASE)

2018-07-17 15:29:29.267  INFO 12312 --- [           main] c.z.e.p.EurekaProviderApplication        : The following profiles are active: dev
2018-07-17 15:29:29.295  INFO 12312 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@51827393: startup date [Tue Jul 17 15:29:29 GMT+08:00 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@4241e0f4
2018-07-17 15:29:30.902  INFO 12312 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'filterRegistrationBean' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=druidDBConfig; factoryMethodName=filterRegistrationBean; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [cn/zhangbox/eureka/provider/config/DruidDBConfig.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=com.alibaba.druid.spring.boot.autoconfigure.stat.DruidWebStatFilterConfiguration; factoryMethodName=filterRegistrationBean; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/alibaba/druid/spring/boot/autoconfigure/stat/DruidWebStatFilterConfiguration.class]]
2018-07-17 15:29:31.251  INFO 12312 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=608dd1ca-975a-302d-aa26-cd8dca769951
2018-07-17 15:29:31.277  INFO 12312 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-07-17 15:29:31.389  INFO 12312 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$d6e9b9c7] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-17 15:29:31.449  INFO 12312 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$f303bcc4] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-17 15:29:32.818  INFO 12312 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2018-07-17 15:29:32.829  INFO 12312 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2018-07-17 15:29:32.830  INFO 12312 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.14
2018-07-17 15:29:33.250  INFO 12312 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-07-17 15:29:33.250  INFO 12312 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3955 ms
2018-07-17 15:29:33.605  INFO 12312 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'statViewServlet' to [/druid/*]
2018-07-17 15:29:33.607  INFO 12312 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2018-07-17 15:29:33.608  INFO 12312 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'statViewServlet' to [/druid/*]
2018-07-17 15:29:33.608  INFO 12312 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet statViewServlet was not registered (possibly already registered?)
2018-07-17 15:29:33.614  INFO 12312 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-07-17 15:29:33.614  INFO 12312 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-07-17 15:29:33.614  INFO 12312 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-07-17 15:29:33.614  INFO 12312 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-07-17 15:29:33.615  INFO 12312 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'webStatFilter' to urls: [/*]
2018-07-17 15:29:36.473  INFO 12312 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/student/list],methods=[GET]}" onto public java.lang.String cn.zhangbox.eureka.provider.controller.StudentConteroller.list(java.lang.String,java.lang.Integer,org.springframework.ui.ModelMap)
2018-07-17 15:29:36.475  INFO 12312 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/v2/api-docs],methods=[GET],produces=[application/json || application/hal+json]}" onto public org.springframework.http.ResponseEntity<springfox.documentation.spring.web.json.Json> springfox.documentation.swagger2.web.Swagger2Controller.getDocumentation(java.lang.String,javax.servlet.http.HttpServletRequest)
2018-07-17 15:29:36.478  INFO 12312 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/swagger-resources/configuration/ui]}" onto org.springframework.http.ResponseEntity<springfox.documentation.swagger.web.UiConfiguration> springfox.documentation.swagger.web.ApiResourceController.uiConfiguration()
2018-07-17 15:29:36.479  INFO 12312 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/swagger-resources]}" onto org.springframework.http.ResponseEntity<java.util.List<springfox.documentation.swagger.web.SwaggerResource>> springfox.documentation.swagger.web.ApiResourceController.swaggerResources()
2018-07-17 15:29:36.480  INFO 12312 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/swagger-resources/configuration/security]}" onto org.springframework.http.ResponseEntity<springfox.documentation.swagger.web.SecurityConfiguration> springfox.documentation.swagger.web.ApiResourceController.securityConfiguration()
2018-07-17 15:29:36.483  INFO 12312 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-07-17 15:29:36.483  INFO 12312 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-07-17 15:29:37.292  INFO 12312 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@51827393: startup date [Tue Jul 17 15:29:29 GMT+08:00 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@4241e0f4
2018-07-17 15:29:37.651  INFO 12312 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-17 15:29:37.651  INFO 12312 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-17 15:29:37.717  INFO 12312 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-17 15:29:38.371  WARN 12312 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2018-07-17 15:29:38.385  INFO 12312 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2018-07-17 15:29:38.390  WARN 12312 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2018-07-17 15:29:38.391  INFO 12312 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2018-07-17 15:29:38.619  INFO 12312 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-07-17 15:29:38.622  INFO 12312 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'statFilter' has been autodetected for JMX exposure
2018-07-17 15:29:38.622  INFO 12312 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'dataSource' has been autodetected for JMX exposure
2018-07-17 15:29:38.631  INFO 12312 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'environmentManager' has been autodetected for JMX exposure
2018-07-17 15:29:38.633  INFO 12312 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'configurationPropertiesRebinder' has been autodetected for JMX exposure
2018-07-17 15:29:38.634  INFO 12312 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'refreshScope' has been autodetected for JMX exposure
2018-07-17 15:29:38.638  INFO 12312 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'environmentManager': registering with JMX server as MBean [org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager]
2018-07-17 15:29:38.942  INFO 12312 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'refreshScope': registering with JMX server as MBean [org.springframework.cloud.context.scope.refresh:name=refreshScope,type=RefreshScope]
2018-07-17 15:29:38.955  INFO 12312 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'configurationPropertiesRebinder': registering with JMX server as MBean [org.springframework.cloud.context.properties:name=configurationPropertiesRebinder,context=51827393,type=ConfigurationPropertiesRebinder]
2018-07-17 15:29:38.963  INFO 12312 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located MBean 'dataSource': registering with JMX server as MBean [com.alibaba.druid.spring.boot.autoconfigure:name=dataSource,type=DruidDataSourceWrapper]
2018-07-17 15:29:38.965  INFO 12312 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located MBean 'statFilter': registering with JMX server as MBean [com.alibaba.druid.filter.stat:name=statFilter,type=StatFilter]
2018-07-17 15:29:39.410  INFO 12312 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
2018-07-17 15:29:39.418  INFO 12312 --- [           main] o.s.c.n.eureka.InstanceInfoFactory       : Setting initial instance status as: STARTING
2018-07-17 15:29:39.548  INFO 12312 --- [           main] com.netflix.discovery.DiscoveryClient    : Initializing Eureka in region us-east-1
2018-07-17 15:29:40.130  INFO 12312 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2018-07-17 15:29:40.131  INFO 12312 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2018-07-17 15:29:40.256  INFO 12312 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2018-07-17 15:29:40.256  INFO 12312 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2018-07-17 15:29:41.457  INFO 12312 --- [           main] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2018-07-17 15:29:41.579  INFO 12312 --- [           main] com.netflix.discovery.DiscoveryClient    : Disable delta property : false
2018-07-17 15:29:41.579  INFO 12312 --- [           main] com.netflix.discovery.DiscoveryClient    : Single vip registry refresh property : null
2018-07-17 15:29:41.579  INFO 12312 --- [           main] com.netflix.discovery.DiscoveryClient    : Force full registry fetch : false
2018-07-17 15:29:41.579  INFO 12312 --- [           main] com.netflix.discovery.DiscoveryClient    : Application is null : false
2018-07-17 15:29:41.579  INFO 12312 --- [           main] com.netflix.discovery.DiscoveryClient    : Registered Applications size is zero : true
2018-07-17 15:29:41.579  INFO 12312 --- [           main] com.netflix.discovery.DiscoveryClient    : Application version is -1: true
2018-07-17 15:29:41.579  INFO 12312 --- [           main] com.netflix.discovery.DiscoveryClient    : Getting all instance registry info from the eureka server
2018-07-17 15:29:42.334  INFO 12312 --- [           main] com.netflix.discovery.DiscoveryClient    : The response status is 200
2018-07-17 15:29:42.336  INFO 12312 --- [           main] com.netflix.discovery.DiscoveryClient    : Starting heartbeat executor: renew interval is: 30
2018-07-17 15:29:42.339  INFO 12312 --- [           main] c.n.discovery.InstanceInfoReplicator     : InstanceInfoReplicator onDemand update allowed rate per min is 4
2018-07-17 15:29:42.344  INFO 12312 --- [           main] com.netflix.discovery.DiscoveryClient    : Discovery Client initialized at timestamp 1531812582343 with initial instances count: 0
2018-07-17 15:29:42.364  INFO 12312 --- [           main] o.s.c.n.e.s.EurekaServiceRegistry        : Registering application eureka-provider with eureka with status UP
2018-07-17 15:29:42.365  INFO 12312 --- [           main] com.netflix.discovery.DiscoveryClient    : Saw local status change event StatusChangeEvent [timestamp=1531812582365, current=UP, previous=STARTING]
2018-07-17 15:29:42.367  INFO 12312 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_EUREKA-PROVIDER/10.25.26.144:8080: registering service...
2018-07-17 15:29:42.369  INFO 12312 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 2147483647
2018-07-17 15:29:42.369  INFO 12312 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2018-07-17 15:29:42.450  INFO 12312 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
2018-07-17 15:29:42.575  INFO 12312 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_EUREKA-PROVIDER/10.25.26.144:8080 - registration status: 204
2018-07-17 15:29:42.741  INFO 12312 --- [           main] s.d.s.w.s.ApiListingReferenceScanner     : Scanning for api listing references
2018-07-17 15:29:42.849  WARN 12312 --- [           main] s.d.s.w.r.p.ParameterDataTypeReader      : Trying to infer dataType org.springframework.ui.ModelMap
2018-07-17 15:29:43.087  INFO 12312 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2018-07-17 15:29:43.088  INFO 12312 --- [           main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8080
2018-07-17 15:29:43.094  INFO 12312 --- [           main] c.z.e.p.EurekaProviderApplication        : Started EurekaProviderApplication in 16.419 seconds (JVM running for 21.462)

至此eureka-provider服務提供者建立完成,瀏覽器輸入地址:http://localhost:1001/
可以看到如下頁面,表示服務註冊OK

圖片.png


點選Status下的ip後可以跳轉看到swagger的頁面並可是測試服務提供者的介面,如下:

圖片.png

 

服務消費者工程配置

這裡構建的工程名為eureka-consumer,上文已經構建了工程但是沒有建立目錄,這裡只需要在java目錄下建立configcontrollerservice,包即可,這裡服務的消費是通過feign來進行服務呼叫的,後面會有專門以篇文章來講feign
首先:eureka-consumer工程下resource目錄下新增application.yml檔案並加入以下配置:

#公共配置
server:
    port: 80
    tomcat:
      uri-encoding: UTF-8
spring:
  #服務名稱,更關鍵,使用feign進行服務消費將以此為依據
  application:
     name: eureka-consumer
  #啟用哪一個環境的配置檔案
  profiles:
    active: dev

#配置eureka獲取服務地址,這裡使用的是本地註冊中心
eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:1001/eureka/
  #配置instance相關資訊
  instance:
      prefer-ip-address: true
      instanceId: ${spring.cloud.client.ipAddress}:${server.port}
      status-page-url: http://${spring.cloud.client.ipAddress}:${server.port}/swagger-ui.html # ${server.port}為該服務的埠號

---
#開發環境配置
server:
  #埠
  port: 8081
spring:
  profiles: dev
#日誌
logging:
  config: classpath:log/logback.xml
  path: log/eureka-consumer

---
#測試環境配置
server:
  #埠
  port: 8082
spring:
  profiles: test
#日誌
logging:
  config: classpath:log/logback.xml
  path: /home/log/eureka-consumer

---
#生產環境配置
server:
  #埠
  port: 8083
spring:
  profiles: prod
#日誌
logging:
  config: classpath:log/logback.xml
  path: /home/log/eureka-consumer

其次:config目錄下增加SwaggerConfig類加入以下程式碼:

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket userApi() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.zhangbox.eureka.consumer.controller"))//過濾的介面,有這掃描才會看到介面資訊
                .paths(PathSelectors.any())
                .build();
        return docket;
    }


    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("eureka服務端消費者介面平臺").description("服務相關資料介面")
                .termsOfServiceUrl("http://www.zhang.box.cn/").contact("技術開發部")
                .license("Licence Version 1.0").licenseUrl("#").version("1.0").build();
    }

}

接著:service包下建立StudentConsumerService類並加入以下程式碼:

@FeignClient(value = "eureka-provider")
public interface StudentConsumerService {

    /**
     * 查詢所有的學生資訊
     *
     * @param sname
     * @param age
     * @return
     */
    @RequestMapping(value = "/student/list",method = RequestMethod.GET)
    String getStudentList(@RequestParam(value = "sname") String sname, @RequestParam(value = "age") Integer age);
}

然後:controller包下建立StudentConteroller並加入如下程式碼:

@Controller
@RequestMapping("/student")
@Api(value = "eureka-consumer", description = "學生查詢介面")
public class StudentConteroller {
    private static final Logger LOGGER = LoggerFactory.getLogger(StudentConteroller.class);

    @Autowired
    StudentConsumerService studentService;

    /**
     * 查詢所有的學生資訊
     *
     * @param sname
     * @param age
     * @param modelMap
     * @return
     */
    @ResponseBody
    @GetMapping("/consumer/list")
    public String list(
            @ApiParam(value = "學生姓名") @RequestParam(required = false) String sname,
            @ApiParam(value = "年齡") @RequestParam(required = false) Integer age,
            ModelMap modelMap) {
        String json = null;
        try {
            json = studentService.getStudentList(sname, age);
        } catch (Exception e) {
            e.printStackTrace();
            modelMap.put("ren_code", "0");
            modelMap.put("ren_msg", "查詢失敗===>" + e);
            LOGGER.error("查詢失敗===>" + e);
            json = JSON.toJSONString(modelMap);
        }
        return json;
    }
}

接著:建立核心啟動類:

@EnableFeignClients//開啟Feign呼叫介面
@EnableDiscoveryClient//開啟客戶端服務,沒有這個註解會報Feign找不到對應服務的錯誤
@SpringBootApplication
public class EurekaConsumerApplication extends SpringBootServletInitializer {

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

最後:啟動專案,看到如下日誌列印資訊:

 .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.3.RELEASE)

2018-07-17 15:56:10.446  INFO 9400 --- [           main] c.z.e.c.EurekaConsumerApplication        : The following profiles are active: dev
2018-07-17 15:56:10.480  INFO 9400 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7a799159: startup date [Tue Jul 17 15:56:10 GMT+08:00 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@3b8f0a79
2018-07-17 15:56:11.536  INFO 9400 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=6ee65f72-d692-3f45-bb25-4625a69b17da
2018-07-17 15:56:11.558  INFO 9400 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-07-17 15:56:11.590  INFO 9400 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'cn.zhangbox.eureka.consumer.service.StudentConsumerService' of type [org.springframework.cloud.netflix.feign.FeignClientFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-17 15:56:11.640  INFO 9400 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$89a7f8be] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-17 15:56:12.196  INFO 9400 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8081 (http)
2018-07-17 15:56:12.265  INFO 9400 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2018-07-17 15:56:12.271  INFO 9400 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.14
2018-07-17 15:56:12.658  INFO 9400 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-07-17 15:56:12.658  INFO 9400 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2178 ms
2018-07-17 15:56:12.841  INFO 9400 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2018-07-17 15:56:12.847  INFO 9400 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-07-17 15:56:12.881  INFO 9400 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-07-17 15:56:12.881  INFO 9400 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-07-17 15:56:12.881  INFO 9400 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-07-17 15:56:12.985  INFO 9400 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@6723610b: startup date [Tue Jul 17 15:56:12 GMT+08:00 2018]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7a799159
2018-07-17 15:56:13.039  INFO 9400 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-07-17 15:56:13.898  INFO 9400 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/student/consumer/list],methods=[GET]}" onto public java.lang.String cn.zhangbox.eureka.consumer.controller.StudentConteroller.list(java.lang.String,java.lang.Integer,org.springframework.ui.ModelMap)
2018-07-17 15:56:13.900  INFO 9400 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/v2/api-docs],methods=[GET],produces=[application/json || application/hal+json]}" onto public org.springframework.http.ResponseEntity<springfox.documentation.spring.web.json.Json> springfox.documentation.swagger2.web.Swagger2Controller.getDocumentation(java.lang.String,javax.servlet.http.HttpServletRequest)
2018-07-17 15:56:13.902  INFO 9400 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/swagger-resources/configuration/ui]}" onto org.springframework.http.ResponseEntity<springfox.documentation.swagger.web.UiConfiguration> springfox.documentation.swagger.web.ApiResourceController.uiConfiguration()
2018-07-17 15:56:13.903  INFO 9400 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/swagger-resources]}" onto org.springframework.http.ResponseEntity<java.util.List<springfox.documentation.swagger.web.SwaggerResource>> springfox.documentation.swagger.web.ApiResourceController.swaggerResources()
2018-07-17 15:56:13.904  INFO 9400 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/swagger-resources/configuration/security]}" onto org.springframework.http.ResponseEntity<springfox.documentation.swagger.web.SecurityConfiguration> springfox.documentation.swagger.web.ApiResourceController.securityConfiguration()
2018-07-17 15:56:13.907  INFO 9400 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-07-17 15:56:13.908  INFO 9400 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-07-17 15:56:14.482  INFO 9400 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7a799159: startup date [Tue Jul 17 15:56:10 GMT+08:00 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@3b8f0a79
2018-07-17 15:56:14.555  INFO 9400 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-17 15:56:14.555  INFO 9400 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-17 15:56:14.643  INFO 9400 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-17 15:56:15.188  WARN 9400 --- [           main] o.s.c.n.a.ArchaiusAutoConfiguration      : No spring.application.name found, defaulting to 'application'
2018-07-17 15:56:15.218  WARN 9400 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2018-07-17 15:56:15.218  INFO 9400 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2018-07-17 15:56:15.223  WARN 9400 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2018-07-17 15:56:15.223  INFO 9400 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2018-07-17 15:56:15.373  INFO 9400 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-07-17 15:56:15.383  INFO 9400 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'environmentManager' has been autodetected for JMX exposure
2018-07-17 15:56:15.385  INFO 9400 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'configurationPropertiesRebinder' has been autodetected for JMX exposure
2018-07-17 15:56:15.387  INFO 9400 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'refreshScope' has been autodetected for JMX exposure
2018-07-17 15:56:15.391  INFO 9400 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'environmentManager': registering with JMX server as MBean [org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager]
2018-07-17 15:56:15.428  INFO 9400 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'refreshScope': registering with JMX server as MBean [org.springframework.cloud.context.scope.refresh:name=refreshScope,type=RefreshScope]
2018-07-17 15:56:15.442  INFO 9400 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'configurationPropertiesRebinder': registering with JMX server as MBean [org.springframework.cloud.context.properties:name=configurationPropertiesRebinder,context=7a799159,type=ConfigurationPropertiesRebinder]
2018-07-17 15:56:15.562  INFO 9400 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
2018-07-17 15:56:15.570  INFO 9400 --- [           main] o.s.c.n.eureka.InstanceInfoFactory       : Setting initial instance status as: STARTING
2018-07-17 15:56:15.634  INFO 9400 --- [           main] com.netflix.discovery.DiscoveryClient    : Initializing Eureka in region us-east-1
2018-07-17 15:56:16.225  INFO 9400 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2018-07-17 15:56:16.225  INFO 9400 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2018-07-17 15:56:16.345  INFO 9400 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2018-07-17 15:56:16.346  INFO 9400 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2018-07-17 15:56:16.826  INFO 9400 --- [           main] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2018-07-17 15:56:16.965  INFO 9400 --- [           main] com.netflix.discovery.DiscoveryClient    : Disable delta property : false
2018-07-17 15:56:16.966  INFO 9400 --- [           main] com.netflix.discovery.DiscoveryClient    : Single vip registry refresh property : null
2018-07-17 15:56:16.966  INFO 9400 --- [           main] com.netflix.discovery.DiscoveryClient    : Force full registry fetch : false
2018-07-17 15:56:16.966  INFO 9400 --- [           main] com.netflix.discovery.DiscoveryClient    : Application is null : false
2018-07-17 15:56:16.966  INFO 9400 --- [           main] com.netflix.discovery.DiscoveryClient    : Registered Applications size is zero : true
2018-07-17 15:56:16.967  INFO 9400 --- [           main] com.netflix.discovery.DiscoveryClient    : Application version is -1: true
2018-07-17 15:56:16.967  INFO 9400 --- [           main] com.netflix.discovery.DiscoveryClient    : Getting all instance registry info from the eureka server
2018-07-17 15:56:17.184  INFO 9400 --- [           main] com.netflix.discovery.DiscoveryClient    : The response status is 200
2018-07-17 15:56:17.186  INFO 9400 --- [           main] com.netflix.discovery.DiscoveryClient    : Starting heartbeat executor: renew interval is: 30
2018-07-17 15:56:17.189  INFO 9400 --- [           main] c.n.discovery.InstanceInfoReplicator     : InstanceInfoReplicator onDemand update allowed rate per min is 4
2018-07-17 15:56:17.195  INFO 9400 --- [           main] com.netflix.discovery.DiscoveryClient    : Discovery Client initialized at timestamp 1531814177194 with initial instances count: 1
2018-07-17 15:56:17.218  INFO 9400 --- [           main] o.s.c.n.e.s.EurekaServiceRegistry        : Registering application unknown with eureka with status UP
2018-07-17 15:56:17.219  INFO 9400 --- [           main] com.netflix.discovery.DiscoveryClient    : Saw local status change event StatusChangeEvent [timestamp=1531814177219, current=UP, previous=STARTING]
2018-07-17 15:56:17.221  INFO 9400 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_UNKNOWN/10.25.26.144:8081: registering service...
2018-07-17 15:56:17.222  INFO 9400 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 2147483647
2018-07-17 15:56:17.223  INFO 9400 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2018-07-17 15:56:17.261  INFO 9400 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_UNKNOWN/10.25.26.144:8081 - registration status: 204
2018-07-17 15:56:17.280  INFO 9400 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
2018-07-17 15:56:17.305  INFO 9400 --- [           main] s.d.s.w.s.ApiListingReferenceScanner     : Scanning for api listing references
2018-07-17 15:56:17.379  WARN 9400 --- [           main] s.d.s.w.r.p.ParameterDataTypeReader      : Trying to infer dataType org.springframework.ui.ModelMap
2018-07-17 15:56:17.614  INFO 9400 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8081 (http)
2018-07-17 15:56:17.616  INFO 9400 --- [           main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8081
2018-07-17 15:56:17.621  INFO 9400 --- [           main] c.z.e.c.EurekaConsumerApplication        : Started EurekaConsumerApplication in 9.852 seconds (JVM running for 12.176)

至此eureka-consumer服務提供者建立完成,瀏覽器輸入地址:http://127.0.0.1:8081/swagger-ui.html
同樣也可以點選eureka控制檯中ApplicationEUREKA-CONSUMERStatus下的ip後可以跳轉看到swagger的頁面並可是測試服務消費者的介面,可以看到如下頁面,並點選try it out按鈕,返回了正確的學生資訊資料

圖片.png


返回資料如下:

圖片.png

 

{
    "ren_code": "0",
    "ren_msg": "查詢成功",
    "studentList": [{
        "age": "17",
        "birth": "2010-07-22",
        "dept": "王同學學習成績很不錯",
        "sex": "1",
        "sname": "王同學",
        "sno": 1
    }, {
        "age": "17",
        "birth": "2010-07-22",
        "dept": "李同學學習成績很不錯",
        "sex": "1",
        "sname": "李同學",
        "sno": 2
    }]
}

以上就是spring cloud基於eurka實現分散式服務註冊與消費的整合流程,是不是很簡單,你也來小試牛刀一把吧。

寫在最後

歡迎關注喜歡、和點贊後續將推出更多的spring cloud教程,敬請期待。

 

作者:星緣1314
連結:https://www.jianshu.com/p/cb57e2ae84f4
來源:簡書
簡書著作權歸作者所有,任何形式的轉載都請聯絡作者獲得授權並註明出處。

關注「程式設計微刊」公眾號 ,在微信後臺回覆「領取資源」,獲取IT資源300G乾貨大全。

公眾號回覆“1”,拉你程式序員技術討論群.

轉載於:https://www.cnblogs.com/wangting888/p/9701396.html

相關文章