SpringCloud核心教程 | 第三篇:服務(wù)注冊(cè)與發(fā)現(xiàn) Eureka篇

Spring Cloud簡(jiǎn)介

Spring Cloud是一個(gè)基于Spring Boot實(shí)現(xiàn)的云應(yīng)用開(kāi)發(fā)工具褪贵,它為基于JVM的云應(yīng)用開(kāi)發(fā)中涉及的配置管理营密、服務(wù)發(fā)現(xiàn)、斷路器、智能路由甫男、微代理、控制總線叹放、全局鎖沐寺、決策競(jìng)選、分布式會(huì)話和集群狀態(tài)管理等操作提供了一種簡(jiǎn)單的開(kāi)發(fā)方式寥枝。

Spring Cloud包含了多個(gè)子項(xiàng)目(針對(duì)分布式系統(tǒng)中涉及的多個(gè)不同開(kāi)源產(chǎn)品)宪塔,比如:Spring Cloud ConfigSpring Cloud Netflix囊拜、Spring Cloud CloudFoundry某筐、Spring Cloud AWSSpring Cloud Security冠跷、Spring Cloud Commons南誊、Spring Cloud ZookeeperSpring Cloud CLI等項(xiàng)目蜜托。

微服務(wù)架構(gòu)

“微服務(wù)架構(gòu)”在這幾年非常的火熱抄囚,以至于關(guān)于微服務(wù)架構(gòu)相關(guān)的開(kāi)源產(chǎn)品被反復(fù)的提及(比如: netflixdubbo)橄务,Spring Cloud也因Spring社區(qū)的強(qiáng)大知名度和影響力也被廣大架構(gòu)師與開(kāi)發(fā)者備受關(guān)注幔托。

那么什么是“微服務(wù)架構(gòu)”呢?簡(jiǎn)單的說(shuō)仪糖,微服務(wù)架構(gòu)就是將一個(gè)完整的應(yīng)用從數(shù)據(jù)存儲(chǔ)開(kāi)始垂直拆分成多個(gè)不同的服務(wù)柑司,每個(gè)服務(wù)都能獨(dú)立部署、獨(dú)立維護(hù)锅劝、獨(dú)立擴(kuò)展攒驰,服務(wù)與服務(wù)間通過(guò)諸如RESTful API的方式互相調(diào)用。

對(duì)于“微服務(wù)架構(gòu)”故爵,大家在互聯(lián)網(wǎng)可以搜索到很多相關(guān)的介紹和研究文章來(lái)進(jìn)行學(xué)習(xí)和了解玻粪。也可以閱讀始祖Martin Fowler的《Microservices》(中文版翻譯點(diǎn)擊查看)隅津,本文不做更多的介紹和描述。

服務(wù)治理

在簡(jiǎn)單介紹了Spring Cloud和微服務(wù)架構(gòu)之后劲室,下面回歸本文的主旨內(nèi)容伦仍,如何使用Spring Cloud來(lái)實(shí)現(xiàn)服務(wù)治理。

由于Spring Cloud為服務(wù)治理做了一層抽象接口很洋,所以在Spring Cloud應(yīng)用中可以支持多種不同的服務(wù)治理框架充蓝,比如:Netflix EurekaConsul喉磁、Zookeeper谓苟。在Spring Cloud服務(wù)治理抽象層的作用下,我們可以無(wú)縫地切換服務(wù)治理實(shí)現(xiàn)协怒,并且不影響任何其他的服務(wù)注冊(cè)涝焙、服務(wù)發(fā)現(xiàn)、服務(wù)調(diào)用等邏輯孕暇。

所以仑撞,下面我們通過(guò)Eureka這種種服務(wù)治理的實(shí)現(xiàn)來(lái)體會(huì)Spring Cloud這一層抽象所帶來(lái)的好處。
下一篇介紹基于Consul的服務(wù)注冊(cè)與調(diào)用妖滔。

Spring Cloud Eureka

首先隧哮,我們來(lái)嘗試使用Spring Cloud Eureka來(lái)實(shí)現(xiàn)服務(wù)治理。

Spring Cloud EurekaSpring Cloud Netflix項(xiàng)目下的服務(wù)治理模塊铛楣。而Spring Cloud Netflix項(xiàng)目是Spring Cloud的子項(xiàng)目之一近迁,主要內(nèi)容是對(duì)Netflix公司一系列開(kāi)源產(chǎn)品的包裝,它為Spring Boot應(yīng)用提供了自配置的Netflix OSS整合簸州。通過(guò)一些簡(jiǎn)單的注解,開(kāi)發(fā)者就可以快速的在應(yīng)用中配置一下常用模塊并構(gòu)建龐大的分布式系統(tǒng)歧譬。它主要提供的模塊包括:服務(wù)發(fā)現(xiàn)(Eureka)岸浑,斷路器(Hystrix),智能路由(Zuul)瑰步,客戶端負(fù)載均衡(Ribbon)等矢洲。

下面,就來(lái)具體看看如何使用Spring Cloud Eureka實(shí)現(xiàn)服務(wù)治理缩焦,這里使用eureka-server為服務(wù)注冊(cè)中心工程读虏、eureka-provider服務(wù)提供者工程、eureka-consumer服務(wù)消費(fèi)者工程袁滥。

準(zhǔn)備工作

環(huán)境:

windows
jdk 8
maven 3.0
IDEA

構(gòu)建工程

首先構(gòu)建父工程盖桥,引入父工程依賴:

<?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
構(gòu)建子工程,分別創(chuàng)建工程名為:eureka-server题翻、eureka-provider揩徊、eureka-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服務(wù)端依賴start -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka-server</artifactId>
        </dependency>
        <!-- 引入eureka服務(wù)端依賴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構(gòu)建插件start -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
    <!-- 添加maven構(gòu)建插件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驅(qū)動(dòng)核心包 start -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <!-- mysql驅(qū)動(dòng)核心包 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構(gòu)建插件start -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <!-- 添加maven構(gòu)建插件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構(gòu)建插件start -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <!-- 添加maven構(gòu)建插件end -->
        </plugins>
    </build>

</project>

工程構(gòu)建完成。

服務(wù)注冊(cè)中心工程配置

首先:eureka-server工程下resource目錄下添加application.yml文件并加入以下配置:

#工程名稱
spring:
  application:
    name: eureka-server
#選擇哪一個(gè)環(huán)境的配置
#這里可以在每個(gè)環(huán)境配置redis,數(shù)據(jù)庫(kù)(mysql)塑荒,消息(kafka)等相關(guān)的組件的配置
  profiles:
    active: dev
#配置eureka注冊(cè)中心
eureka:
  #server:
    #配置關(guān)閉自我保護(hù)模式
    #enableSelfPreservation: false
    #配置Eureka Server清理無(wú)效節(jié)點(diǎn)的時(shí)間間隔
    #eviction-interval-timer-in-ms: 4000
  instance:
    #配置與此實(shí)例相關(guān)聯(lián)的主機(jī)名熄赡,是其他實(shí)例可以用來(lái)進(jìn)行請(qǐng)求的準(zhǔn)確名稱
    hostname: eureka-server
    #顯示服務(wù)ip地址
    preferIpAddress: true
    #獲取服務(wù)的ip和端口
    instanceId: ${spring.cloud.client.ipAddress}:${server.port}
  client:
    #配置不將自己注冊(cè)到eureka注冊(cè)中心
    register-with-eureka: false
    #配置此客戶端不獲取eureka服務(wù)器注冊(cè)表上的注冊(cè)信息
    fetch-registry: false
    serviceUrl:
          #配置默認(rèn)節(jié)點(diǎn)有信息,這里是獲取本機(jī)的ip和端口來(lái)實(shí)現(xiàn)齿税,如果不配置彼硫,默認(rèn)會(huì)找8761端口,這里配置的是1001端口凌箕,因此會(huì)報(bào)錯(cuò)
          defaultZone: http://${spring.cloud.client.ipAddress}:${server.port}/eureka/
      
#文檔塊區(qū)分為三個(gè)---
---
server:
  port: 1001
spring:
  profiles: dev
#日志
logging:
  config: classpath:log/logback.xml
  path: log/eureka-server

#文檔塊區(qū)分為三個(gè)---
---
server:
  port: 1002
spring:
  profiles: test
#日志
logging:
  config: classpath:log/logback.xml
  path: usr/eureka-server/log/eureka-server

#文檔塊區(qū)分為三個(gè)---
---
server:
  port: 1003
spring:
  profiles: prod
#日志
logging:
  config: classpath:log/logback.xml
  path: usr/eureka-server/log/eureka-server

這里日志的配置不在詳細(xì)說(shuō)明拧篮,不知道怎么配置可以參考這篇文章:
SpringBoot進(jìn)階教程 | 第二篇:日志組件logback實(shí)現(xiàn)日志分級(jí)打印

其次:創(chuàng)建核心啟動(dòng)類:

@EnableEurekaServer//加上此注解表示將此工程啟動(dòng)后為注冊(cè)中心
@SpringBootApplication
public class EurekaServerApplication {

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

}

最后:啟動(dòng)項(xiàng)目,看到如下日志打印信息:

 .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: 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注冊(cè)中心創(chuàng)建完成陌知,瀏覽器輸入地址:http://localhost:1001/
可以看到如下頁(yè)面他托,表示服務(wù)啟動(dòng)OK

圖片.png

這里這看到還沒(méi)有服務(wù)暴露出來(lái),是因?yàn)檫€沒(méi)創(chuàng)建服務(wù)提供者工程仆葡。

服務(wù)提供者工程配置

這里服務(wù)提供者是使用之前SpringBoot進(jìn)階教程 | 第三篇:整合Druid連接池以及Druid監(jiān)控改造而來(lái)赏参,這里一樣的部分就不再重復(fù)說(shuō)明,下面將說(shuō)明新增的部分沿盅。
首先:修改application.yml配置為如下:

#公共配置
server:
    port: 80
    tomcat:
      uri-encoding: UTF-8
spring:
  application:
      #服務(wù)名稱把篓,更關(guān)鍵,使用feign進(jìn)行服務(wù)消費(fèi)將以此為依據(jù)
      name: eureka-provider
  #激活哪一個(gè)環(huán)境的配置文件
  profiles:
    active: dev
  #連接池配置
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    # 使用druid數(shù)據(jù)源
    type: com.alibaba.druid.pool.DruidDataSource
    druid:
      # 配置測(cè)試查詢語(yǔ)句
      validationQuery: SELECT 1 FROM DUAL
      # 初始化大小腰涧,最小韧掩,最大
      initialSize: 10
      minIdle: 10
      maxActive: 200
      # 配置一個(gè)連接在池中最小生存的時(shí)間,單位是毫秒
      minEvictableIdleTimeMillis: 180000
      testOnBorrow: false
      testWhileIdle: true
      removeAbandoned: true
      removeAbandonedTimeout: 1800
      logAbandoned: true
      # 打開(kāi)PSCache窖铡,并且指定每個(gè)連接上PSCache的大小
      poolPreparedStatements: true
      maxOpenPreparedStatements: 100
      # 配置監(jiān)控統(tǒng)計(jì)攔截的filters疗锐,去掉后監(jiān)控界面sql無(wú)法統(tǒng)計(jì),'wall'用于防火墻
      filters: stat,wall,log4j
      # 通過(guò)connectProperties屬性來(lái)打開(kāi)mergeSql功能费彼;慢SQL記錄
      connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000

#配置eureka獲取服務(wù)地址滑臊,這里使用的是本地注冊(cè)中心
eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:1001/eureka/
  #配置Swagger相關(guān)信息
  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}為該服務(wù)的端口號(hào)

#mybatis
mybatis:
  # 實(shí)體類掃描
  type-aliases-package: cn.zhangbox.springboot.entity
  # 配置映射文件位置
  mapper-locations: classpath:mapper/*.xml
  # 開(kāi)啟駝峰匹配
  mapUnderscoreToCamelCase: true

---
#開(kāi)發(fā)環(huán)境配置
server:
  #端口
  port: 8080
spring:
  profiles: dev
  # 數(shù)據(jù)源配置
  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

---
#測(cè)試環(huán)境配置
server:
  #端口
  port: 80
spring:
  profiles: test
  # 數(shù)據(jù)源配置
  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

---
#生產(chǎn)環(huán)境配置
server:
  #端口
  port: 8080
spring:
  profiles: prod
  # 數(shù)據(jù)源配置
  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"))//過(guò)濾的接口,有這掃描才會(huì)看到接口信息
                .paths(PathSelectors.any())
                .build();
        return docket;
    }


    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("eureka服務(wù)端提供者接口平臺(tái)").description("服務(wù)相關(guān)數(shù)據(jù)接口")
                .termsOfServiceUrl("http://www.zhang.box.cn/").contact("技術(shù)開(kāi)發(fā)部")
                .license("Licence Version 1.0").licenseUrl("#").version("1.0").build();
    }

}

這里如果不會(huì)使用swagger的整合可以參考這篇文章:
SpringBoot非官方教程 | 第十一篇:SpringBoot集成swagger2箍铲,構(gòu)建優(yōu)雅的Restful API

接著:創(chuàng)建核心啟動(dòng)類:

@EnableDiscoveryClient //使用該注解將注冊(cè)服務(wù)到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);
    }
}

最后:啟動(dòng)項(xiàng)目雇卷,看到如下日志打印信息:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: 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服務(wù)提供者創(chuàng)建完成,瀏覽器輸入地址:http://localhost:1001/
可以看到如下頁(yè)面颠猴,表示服務(wù)注冊(cè)O(shè)K

圖片.png

點(diǎn)擊Status下的ip后可以跳轉(zhuǎn)看到swagger的頁(yè)面并可是測(cè)試服務(wù)提供者的接口关划,如下:
圖片.png

服務(wù)消費(fèi)者工程配置

這里構(gòu)建的工程名為eureka-consumer,上文已經(jīng)構(gòu)建了工程但是沒(méi)有創(chuàng)建目錄,這里只需要在java目錄下創(chuàng)建config翘瓮、controller贮折,service,包即可春畔,這里服務(wù)的消費(fèi)是通過(guò)feign來(lái)進(jìn)行服務(wù)調(diào)用的脱货,后面會(huì)有專門以篇文章來(lái)講feign岛都。
首先:eureka-consumer工程下resource目錄下添加application.yml文件并加入以下配置:

#公共配置
server:
    port: 80
    tomcat:
      uri-encoding: UTF-8
spring:
  #服務(wù)名稱,更關(guān)鍵振峻,使用feign進(jìn)行服務(wù)消費(fèi)將以此為依據(jù)
  application:
     name: eureka-consumer
  #激活哪一個(gè)環(huán)境的配置文件
  profiles:
    active: dev

#配置eureka獲取服務(wù)地址臼疫,這里使用的是本地注冊(cè)中心
eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:1001/eureka/
  #配置instance相關(guān)信息
  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}為該服務(wù)的端口號(hào)

---
#開(kāi)發(fā)環(huán)境配置
server:
  #端口
  port: 8081
spring:
  profiles: dev
#日志
logging:
  config: classpath:log/logback.xml
  path: log/eureka-consumer

---
#測(cè)試環(huán)境配置
server:
  #端口
  port: 8082
spring:
  profiles: test
#日志
logging:
  config: classpath:log/logback.xml
  path: /home/log/eureka-consumer

---
#生產(chǎn)環(huán)境配置
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"))//過(guò)濾的接口,有這掃描才會(huì)看到接口信息
                .paths(PathSelectors.any())
                .build();
        return docket;
    }


    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("eureka服務(wù)端消費(fèi)者接口平臺(tái)").description("服務(wù)相關(guān)數(shù)據(jù)接口")
                .termsOfServiceUrl("http://www.zhang.box.cn/").contact("技術(shù)開(kāi)發(fā)部")
                .license("Licence Version 1.0").licenseUrl("#").version("1.0").build();
    }

}

接著:service包下創(chuàng)建StudentConsumerService類并加入以下代碼:

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

    /**
     * 查詢所有的學(xué)生信息
     *
     * @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包下創(chuàng)建StudentConteroller并加入如下代碼:

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

    @Autowired
    StudentConsumerService studentService;

    /**
     * 查詢所有的學(xué)生信息
     *
     * @param sname
     * @param age
     * @param modelMap
     * @return
     */
    @ResponseBody
    @GetMapping("/consumer/list")
    public String list(
            @ApiParam(value = "學(xué)生姓名") @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;
    }
}

接著:創(chuàng)建核心啟動(dòng)類:

@EnableFeignClients//開(kāi)啟Feign調(diào)用接口
@EnableDiscoveryClient//開(kāi)啟客戶端服務(wù)扣孟,沒(méi)有這個(gè)注解會(huì)報(bào)Feign找不到對(duì)應(yīng)服務(wù)的錯(cuò)誤
@SpringBootApplication
public class EurekaConsumerApplication extends SpringBootServletInitializer {

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

最后:啟動(dòng)項(xiàng)目烫堤,看到如下日志打印信息:

 .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: 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服務(wù)提供者創(chuàng)建完成,瀏覽器輸入地址:http://127.0.0.1:8081/swagger-ui.html
同樣也可以點(diǎn)擊eureka控制臺(tái)中ApplicationEUREKA-CONSUMERStatus下的ip后可以跳轉(zhuǎn)看到swagger的頁(yè)面并可是測(cè)試服務(wù)消費(fèi)者的接口,可以看到如下頁(yè)面凤价,并點(diǎn)擊try it out按鈕鸽斟,返回了正確的學(xué)生信息數(shù)據(jù)

圖片.png

返回?cái)?shù)據(jù)如下:
圖片.png

{
    "ren_code": "0",
    "ren_msg": "查詢成功",
    "studentList": [{
        "age": "17",
        "birth": "2010-07-22",
        "dept": "王同學(xué)學(xué)習(xí)成績(jī)很不錯(cuò)",
        "sex": "1",
        "sname": "王同學(xué)",
        "sno": 1
    }, {
        "age": "17",
        "birth": "2010-07-22",
        "dept": "李同學(xué)學(xué)習(xí)成績(jī)很不錯(cuò)",
        "sex": "1",
        "sname": "李同學(xué)",
        "sno": 2
    }]
}

以上就是spring cloud基于eurka實(shí)現(xiàn)分布式服務(wù)注冊(cè)與消費(fèi)的整合流程,是不是很簡(jiǎn)單利诺,你也來(lái)小試牛刀一把吧富蓄。

源碼地址:

SpringCloud核心教程 | 第三篇:服務(wù)注冊(cè)與發(fā)現(xiàn) Eureka篇

寫在最后

歡迎關(guān)注喜歡慢逾、和點(diǎn)贊后續(xù)將推出更多的思維導(dǎo)圖學(xué)習(xí)文章立倍,敬請(qǐng)期待。
歡迎關(guān)注我的微信公眾號(hào)獲取更多更全的學(xué)習(xí)資源侣滩,視頻資料口注,技術(shù)干貨!

歡迎掃碼關(guān)注

公眾號(hào)回復(fù)“學(xué)習(xí)”君珠,拉你進(jìn)程序員技術(shù)討論群寝志,干貨資源第一時(shí)間分享。

公眾號(hào)回復(fù)“視頻”策添,領(lǐng)取800GJava視頻學(xué)習(xí)資源材部。

公眾號(hào)回復(fù)“全棧”,領(lǐng)取1T前端唯竹,Java败富,產(chǎn)品經(jīng)理微信小程序摩窃,Python等資源合集大放送。

公眾號(hào)回復(fù)“慕課”芬骄,領(lǐng)取1T慕課實(shí)戰(zhàn)學(xué)習(xí)資源猾愿。

公眾號(hào)回復(fù)“實(shí)戰(zhàn)”,領(lǐng)取750G項(xiàng)目實(shí)戰(zhàn)學(xué)習(xí)資源账阻。

公眾號(hào)回復(fù)“面試”蒂秘,領(lǐng)取20G面試實(shí)戰(zhàn)學(xué)習(xí)資源。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末淘太,一起剝皮案震驚了整個(gè)濱河市姻僧,隨后出現(xiàn)的幾起案子规丽,更是在濱河造成了極大的恐慌,老刑警劉巖撇贺,帶你破解...
    沈念sama閱讀 217,734評(píng)論 6 505
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件赌莺,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡松嘶,警方通過(guò)查閱死者的電腦和手機(jī)艘狭,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,931評(píng)論 3 394
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)翠订,“玉大人巢音,你說(shuō)我怎么就攤上這事【〕” “怎么了官撼?”我有些...
    開(kāi)封第一講書人閱讀 164,133評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)似谁。 經(jīng)常有香客問(wèn)我傲绣,道長(zhǎng),這世上最難降的妖魔是什么棘脐? 我笑而不...
    開(kāi)封第一講書人閱讀 58,532評(píng)論 1 293
  • 正文 為了忘掉前任斜筐,我火速辦了婚禮,結(jié)果婚禮上蛀缝,老公的妹妹穿的比我還像新娘顷链。我一直安慰自己,他們只是感情好屈梁,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,585評(píng)論 6 392
  • 文/花漫 我一把揭開(kāi)白布嗤练。 她就那樣靜靜地躺著,像睡著了一般在讶。 火紅的嫁衣襯著肌膚如雪煞抬。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書人閱讀 51,462評(píng)論 1 302
  • 那天构哺,我揣著相機(jī)與錄音革答,去河邊找鬼。 笑死曙强,一個(gè)胖子當(dāng)著我的面吹牛残拐,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播碟嘴,決...
    沈念sama閱讀 40,262評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼溪食,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了娜扇?” 一聲冷哼從身側(cè)響起错沃,我...
    開(kāi)封第一講書人閱讀 39,153評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤栅组,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后枢析,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體玉掸,經(jīng)...
    沈念sama閱讀 45,587評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,792評(píng)論 3 336
  • 正文 我和宋清朗相戀三年登疗,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了排截。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,919評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡辐益,死狀恐怖断傲,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情智政,我是刑警寧澤认罩,帶...
    沈念sama閱讀 35,635評(píng)論 5 345
  • 正文 年R本政府宣布,位于F島的核電站续捂,受9級(jí)特大地震影響垦垂,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜牙瓢,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,237評(píng)論 3 329
  • 文/蒙蒙 一劫拗、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧矾克,春花似錦页慷、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書人閱讀 31,855評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至控妻,卻和暖如春州袒,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背弓候。 一陣腳步聲響...
    開(kāi)封第一講書人閱讀 32,983評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工郎哭, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人菇存。 一個(gè)月前我還...
    沈念sama閱讀 48,048評(píng)論 3 370
  • 正文 我出身青樓彰居,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親撰筷。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,864評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容