spring-cloud-eureka服务发现注册中心及spring-cloud微服务

spring-cloud 使用eureka作为服务注册与发现中心,与zookeeper不同,eureka没有提供可直接运行的压缩文件,需要我们手动搭建eureka服务器。spring-cloud 与dubbo区别参考 https://www.cnblogs.com/aspirant/p/9089146.html

eureka服务器的搭建很简单与一般的spring-boot应用相同,只是启动类需要加上EnableEurekaServer注解并加上相应的配置

下面是我的eureka服务器

首先新建eureka项目

com.wl.springcloud
eureka
1.0-SNAPSHOT

pom.xml        主要依赖spring-cloud-starter-netflix-eureka-server




  4.0.0

  com.wl.springcloud
  eureka
  1.0-SNAPSHOT

  eureka
  
  http://www.example.com

  
    UTF-8
    1.8
    1.8
    2.0.0.RELEASE
    2.0.0.RELEASE
    2.0.3.RELEASE
    com.wl.springcloud.eureka.EurekaApplication
  

  
    
      org.springframework.boot
      spring-boot-starter-web
      ${spring-boot-version}
    

    
      org.springframework.cloud
      spring-cloud-starter-netflix-eureka-server
      ${spring-cloud-eureka-server}
    
    
      org.springframework.cloud
      spring-cloud-starter-config
      ${spring-cloud-config-version}
    
    
      org.springframework.boot
      spring-boot-starter-test
      ${spring-boot-version}
      test
    
  

  
  
    
      
        org.springframework.boot
        spring-boot-maven-plugin
        ${spring-boot-version}
        
          ${MainClass}
          JAR
        
        
        
          
            
              repackage
            
          
        
      
      
      
        org.apache.maven.plugins
        maven-compiler-plugin
        3.1
        
          1.8
          1.8
        
      
    
    
    
      
        src/main/resources
        
          **/*.*
          *.*
        
      
      
        src/main/java
        
          **/*.*
          *.*
        
      
    
  



application.properties    spring-cloud-eureka详细配置参考  https://www.cnblogs.com/chry/p/7992885.html

server.port=8761
#是否注册到eureka-server
eureka.client.register-with-eureka=false
#否从eureka服务器获取注册信息
eureka.client.fetch-registry=false
#在Eureka服务器获取不到集群里对等服务器上的实例时,需要等待的时间,单位为毫秒,默认为1000 * 60 * 5
eureka.server.waitTimeInMsWhenSyncEmpty=0

启动类  spring-boot 2.0.0以上需要引入gson我没有引用所以在exclude 加入了GsonAutoConfiguration

package com.wl.springcloud.eureka;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

/**
 * Created by Administrator on 2019/3/10.
 */
@SpringBootApplication(exclude = {
        DataSourceAutoConfiguration.class,
        DataSourceTransactionManagerAutoConfiguration.class,
        HibernateJpaAutoConfiguration.class,             //不使用数据库
        GsonAutoConfiguration.class                      //2.0.0以上版本需要引入高版本的gson依赖,如果不引用gson依赖需要加此属性
},scanBasePackages = "com.wl")
@EnableEurekaServer
public class EurekaApplication {

    private static final Logger logger = LoggerFactory.getLogger(EurekaApplication.class);

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(EurekaApplication.class);
        app.setWebApplicationType(WebApplicationType.SERVLET);
        app.run(args);
        logger.info("application init success");
    }

}

注意EnableEurekaServer注解

启动

"D:\Program Files\Java\jdk1.8.0_181\bin\java" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:62239,suspend=y,server=n -Dfile.encoding=UTF-8 -classpath "D:\Program Files\Java\jdk1.8.0_181\jre\lib\charsets.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\deploy.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\access-bridge-64.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\cldrdata.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\dnsns.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jaccess.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jfxrt.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\localedata.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\nashorn.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunec.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunjce_provider.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunmscapi.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunpkcs11.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\zipfs.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\javaws.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jce.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jfr.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jfxswt.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jsse.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\management-agent.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\plugin.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\resources.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\rt.jar;D:\workspace\wl\study\spring-cloud\eureka\target\classes;D:\maven\repo\org\springframework\boot\spring-boot-starter-web\2.0.3.RELEASE\spring-boot-starter-web-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter\2.0.3.RELEASE\spring-boot-starter-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot\2.0.3.RELEASE\spring-boot-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-autoconfigure\2.0.3.RELEASE\spring-boot-autoconfigure-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-logging\2.0.3.RELEASE\spring-boot-starter-logging-2.0.3.RELEASE.jar;D:\maven\repo\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;D:\maven\repo\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;D:\maven\repo\org\apache\logging\log4j\log4j-to-slf4j\2.10.0\log4j-to-slf4j-2.10.0.jar;D:\maven\repo\org\apache\logging\log4j\log4j-api\2.10.0\log4j-api-2.10.0.jar;D:\maven\repo\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;D:\maven\repo\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;D:\maven\repo\org\yaml\snakeyaml\1.19\snakeyaml-1.19.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-json\2.0.3.RELEASE\spring-boot-starter-json-2.0.3.RELEASE.jar;D:\maven\repo\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.9.6\jackson-datatype-jdk8-2.9.6.jar;D:\maven\repo\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.9.6\jackson-datatype-jsr310-2.9.6.jar;D:\maven\repo\com\fasterxml\jackson\module\jackson-module-parameter-names\2.9.6\jackson-module-parameter-names-2.9.6.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-tomcat\2.0.3.RELEASE\spring-boot-starter-tomcat-2.0.3.RELEASE.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-core\8.5.31\tomcat-embed-core-8.5.31.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-el\8.5.31\tomcat-embed-el-8.5.31.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-websocket\8.5.31\tomcat-embed-websocket-8.5.31.jar;D:\maven\repo\org\hibernate\validator\hibernate-validator\6.0.10.Final\hibernate-validator-6.0.10.Final.jar;D:\maven\repo\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;D:\maven\repo\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;D:\maven\repo\com\fasterxml\classmate\1.3.4\classmate-1.3.4.jar;D:\maven\repo\org\springframework\spring-web\5.0.7.RELEASE\spring-web-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\spring-beans\5.0.7.RELEASE\spring-beans-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\spring-webmvc\5.0.7.RELEASE\spring-webmvc-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\spring-aop\5.0.7.RELEASE\spring-aop-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\spring-context\5.0.7.RELEASE\spring-context-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\spring-expression\5.0.7.RELEASE\spring-expression-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter-netflix-eureka-server\2.0.0.RELEASE\spring-cloud-starter-netflix-eureka-server-2.0.0.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter\2.0.0.RELEASE\spring-cloud-starter-2.0.0.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-context\2.0.0.RELEASE\spring-cloud-context-2.0.0.RELEASE.jar;D:\maven\repo\org\springframework\security\spring-security-crypto\5.0.6.RELEASE\spring-security-crypto-5.0.6.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-commons\2.0.0.RELEASE\spring-cloud-commons-2.0.0.RELEASE.jar;D:\maven\repo\org\springframework\security\spring-security-rsa\1.0.5.RELEASE\spring-security-rsa-1.0.5.RELEASE.jar;D:\maven\repo\org\bouncycastle\bcpkix-jdk15on\1.56\bcpkix-jdk15on-1.56.jar;D:\maven\repo\org\bouncycastle\bcprov-jdk15on\1.56\bcprov-jdk15on-1.56.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-netflix-eureka-server\2.0.0.RELEASE\spring-cloud-netflix-eureka-server-2.0.0.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-actuator\2.0.3.RELEASE\spring-boot-starter-actuator-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-actuator-autoconfigure\2.0.3.RELEASE\spring-boot-actuator-autoconfigure-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-actuator\2.0.3.RELEASE\spring-boot-actuator-2.0.3.RELEASE.jar;D:\maven\repo\io\micrometer\micrometer-core\1.0.5\micrometer-core-1.0.5.jar;D:\maven\repo\org\hdrhistogram\HdrHistogram\2.1.10\HdrHistogram-2.1.10.jar;D:\maven\repo\org\latencyutils\LatencyUtils\2.0.3\LatencyUtils-2.0.3.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-freemarker\2.0.3.RELEASE\spring-boot-starter-freemarker-2.0.3.RELEASE.jar;D:\maven\repo\org\freemarker\freemarker\2.3.28\freemarker-2.3.28.jar;D:\maven\repo\org\springframework\spring-context-support\5.0.7.RELEASE\spring-context-support-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-netflix-core\2.0.0.RELEASE\spring-cloud-netflix-core-2.0.0.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-aop\2.0.3.RELEASE\spring-boot-starter-aop-2.0.3.RELEASE.jar;D:\maven\repo\org\aspectj\aspectjweaver\1.8.13\aspectjweaver-1.8.13.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-netflix-eureka-client\2.0.0.RELEASE\spring-cloud-netflix-eureka-client-2.0.0.RELEASE.jar;D:\maven\repo\com\netflix\eureka\eureka-client\1.9.2\eureka-client-1.9.2.jar;D:\maven\repo\org\codehaus\jettison\jettison\1.3.7\jettison-1.3.7.jar;D:\maven\repo\stax\stax-api\1.0.1\stax-api-1.0.1.jar;D:\maven\repo\com\netflix\netflix-commons\netflix-eventbus\0.3.0\netflix-eventbus-0.3.0.jar;D:\maven\repo\com\netflix\netflix-commons\netflix-infix\0.3.0\netflix-infix-0.3.0.jar;D:\maven\repo\commons-jxpath\commons-jxpath\1.3\commons-jxpath-1.3.jar;D:\maven\repo\org\antlr\antlr-runtime\3.4\antlr-runtime-3.4.jar;D:\maven\repo\org\antlr\stringtemplate\3.2.1\stringtemplate-3.2.1.jar;D:\maven\repo\antlr\antlr\2.7.7\antlr-2.7.7.jar;D:\maven\repo\com\google\code\gson\gson\2.1\gson-2.1.jar;D:\maven\repo\org\apache\commons\commons-math\2.2\commons-math-2.2.jar;D:\maven\repo\javax\ws\rs\jsr311-api\1.1.1\jsr311-api-1.1.1.jar;D:\maven\repo\com\netflix\servo\servo-core\0.12.21\servo-core-0.12.21.jar;D:\maven\repo\com\sun\jersey\jersey-core\1.19.1\jersey-core-1.19.1.jar;D:\maven\repo\com\sun\jersey\jersey-client\1.19.1\jersey-client-1.19.1.jar;D:\maven\repo\com\sun\jersey\contribs\jersey-apache-client4\1.19.1\jersey-apache-client4-1.19.1.jar;D:\maven\repo\org\apache\httpcomponents\httpclient\4.5.3\httpclient-4.5.3.jar;D:\maven\repo\org\apache\httpcomponents\httpcore\4.4.6\httpcore-4.4.6.jar;D:\maven\repo\commons-codec\commons-codec\1.9\commons-codec-1.9.jar;D:\maven\repo\com\google\inject\guice\4.1.0\guice-4.1.0.jar;D:\maven\repo\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;D:\maven\repo\com\github\vlsi\compactmap\compactmap\1.2.1\compactmap-1.2.1.jar;D:\maven\repo\com\github\andrewoma\dexx\dexx-collections\0.2\dexx-collections-0.2.jar;D:\maven\repo\com\sun\jersey\jersey-servlet\1.19.1\jersey-servlet-1.19.1.jar;D:\maven\repo\com\sun\jersey\jersey-server\1.19.1\jersey-server-1.19.1.jar;D:\maven\repo\com\netflix\eureka\eureka-core\1.9.2\eureka-core-1.9.2.jar;D:\maven\repo\com\amazonaws\aws-java-sdk-core\1.11.277\aws-java-sdk-core-1.11.277.jar;D:\maven\repo\commons-logging\commons-logging\1.1.3\commons-logging-1.1.3.jar;D:\maven\repo\software\amazon\ion\ion-java\1.0.2\ion-java-1.0.2.jar;D:\maven\repo\com\fasterxml\jackson\dataformat\jackson-dataformat-cbor\2.6.7\jackson-dataformat-cbor-2.6.7.jar;D:\maven\repo\joda-time\joda-time\2.8.1\joda-time-2.8.1.jar;D:\maven\repo\com\amazonaws\aws-java-sdk-ec2\1.11.277\aws-java-sdk-ec2-1.11.277.jar;D:\maven\repo\com\amazonaws\jmespath-java\1.11.277\jmespath-java-1.11.277.jar;D:\maven\repo\com\amazonaws\aws-java-sdk-autoscaling\1.11.277\aws-java-sdk-autoscaling-1.11.277.jar;D:\maven\repo\com\amazonaws\aws-java-sdk-sts\1.11.277\aws-java-sdk-sts-1.11.277.jar;D:\maven\repo\com\amazonaws\aws-java-sdk-route53\1.11.277\aws-java-sdk-route53-1.11.277.jar;D:\maven\repo\javax\servlet\servlet-api\2.5\servlet-api-2.5.jar;D:\maven\repo\org\codehaus\woodstox\woodstox-core-asl\4.4.1\woodstox-core-asl-4.4.1.jar;D:\maven\repo\javax\xml\stream\stax-api\1.0-2\stax-api-1.0-2.jar;D:\maven\repo\com\netflix\archaius\archaius-core\0.7.6\archaius-core-0.7.6.jar;D:\maven\repo\com\google\code\findbugs\jsr305\3.0.1\jsr305-3.0.1.jar;D:\maven\repo\com\google\guava\guava\16.0\guava-16.0.jar;D:\maven\repo\javax\inject\javax.inject\1\javax.inject-1.jar;D:\maven\repo\com\fasterxml\jackson\dataformat\jackson-dataformat-xml\2.9.6\jackson-dataformat-xml-2.9.6.jar;D:\maven\repo\com\fasterxml\jackson\module\jackson-module-jaxb-annotations\2.9.6\jackson-module-jaxb-annotations-2.9.6.jar;D:\maven\repo\org\codehaus\woodstox\stax2-api\3.1.4\stax2-api-3.1.4.jar;D:\maven\repo\com\fasterxml\woodstox\woodstox-core\5.0.3\woodstox-core-5.0.3.jar;D:\maven\repo\com\thoughtworks\xstream\xstream\1.4.10\xstream-1.4.10.jar;D:\maven\repo\xmlpull\xmlpull\1.1.3.1\xmlpull-1.1.3.1.jar;D:\maven\repo\xpp3\xpp3_min\1.1.4c\xpp3_min-1.1.4c.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter-netflix-archaius\2.0.0.RELEASE\spring-cloud-starter-netflix-archaius-2.0.0.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-netflix-ribbon\2.0.0.RELEASE\spring-cloud-netflix-ribbon-2.0.0.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-netflix-archaius\2.0.0.RELEASE\spring-cloud-netflix-archaius-2.0.0.RELEASE.jar;D:\maven\repo\commons-configuration\commons-configuration\1.8\commons-configuration-1.8.jar;D:\maven\repo\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter-netflix-ribbon\2.0.0.RELEASE\spring-cloud-starter-netflix-ribbon-2.0.0.RELEASE.jar;D:\maven\repo\com\netflix\ribbon\ribbon\2.2.5\ribbon-2.2.5.jar;D:\maven\repo\com\netflix\ribbon\ribbon-transport\2.2.5\ribbon-transport-2.2.5.jar;D:\maven\repo\io\reactivex\rxnetty-contexts\0.4.9\rxnetty-contexts-0.4.9.jar;D:\maven\repo\io\reactivex\rxnetty-servo\0.4.9\rxnetty-servo-0.4.9.jar;D:\maven\repo\com\netflix\hystrix\hystrix-core\1.4.3\hystrix-core-1.4.3.jar;D:\maven\repo\io\reactivex\rxnetty\0.4.9\rxnetty-0.4.9.jar;D:\maven\repo\io\netty\netty-codec-http\4.0.27.Final\netty-codec-http-4.0.27.Final.jar;D:\maven\repo\io\netty\netty-codec\4.0.27.Final\netty-codec-4.0.27.Final.jar;D:\maven\repo\io\netty\netty-handler\4.0.27.Final\netty-handler-4.0.27.Final.jar;D:\maven\repo\io\netty\netty-transport-native-epoll\4.0.27.Final\netty-transport-native-epoll-4.0.27.Final.jar;D:\maven\repo\io\netty\netty-common\4.0.27.Final\netty-common-4.0.27.Final.jar;D:\maven\repo\io\netty\netty-buffer\4.0.27.Final\netty-buffer-4.0.27.Final.jar;D:\maven\repo\io\netty\netty-transport\4.0.27.Final\netty-transport-4.0.27.Final.jar;D:\maven\repo\com\netflix\ribbon\ribbon-core\2.2.5\ribbon-core-2.2.5.jar;D:\maven\repo\com\netflix\ribbon\ribbon-httpclient\2.2.5\ribbon-httpclient-2.2.5.jar;D:\maven\repo\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;D:\maven\repo\com\netflix\netflix-commons\netflix-commons-util\0.1.1\netflix-commons-util-0.1.1.jar;D:\maven\repo\com\netflix\ribbon\ribbon-loadbalancer\2.2.5\ribbon-loadbalancer-2.2.5.jar;D:\maven\repo\com\netflix\netflix-commons\netflix-statistics\0.1.1\netflix-statistics-0.1.1.jar;D:\maven\repo\io\reactivex\rxjava\1.2.0\rxjava-1.2.0.jar;D:\maven\repo\com\netflix\ribbon\ribbon-eureka\2.2.5\ribbon-eureka-2.2.5.jar;D:\maven\repo\org\slf4j\slf4j-api\1.7.12\slf4j-api-1.7.12.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter-config\2.0.0.RELEASE\spring-cloud-starter-config-2.0.0.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-config-client\2.0.0.RELEASE\spring-cloud-config-client-2.0.0.RELEASE.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-annotations\2.9.0\jackson-annotations-2.9.0.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-databind\2.9.6\jackson-databind-2.9.6.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-core\2.9.6\jackson-core-2.9.6.jar;D:\maven\repo\org\springframework\spring-core\5.0.7.RELEASE\spring-core-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\spring-jcl\5.0.7.RELEASE\spring-jcl-5.0.7.RELEASE.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2017.1.6\lib\idea_rt.jar" com.wl.springcloud.eureka.EurekaApplication
Connected to the target VM, address: '127.0.0.1:62239', transport: 'socket'
2019-03-11 15:34:09.229  INFO 8376 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@446a1e84: startup date [Mon Mar 11 15:34:09 CST 2019]; root of context hierarchy
2019-03-11 15:34:09.409  INFO 8376 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-03-11 15:34:09.432  INFO 8376 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$bb70d5b8] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

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

2019-03-11 15:34:10.713  INFO 8376 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2019-03-11 15:34:11.819  INFO 8376 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8888. Will be trying the next url if available
2019-03-11 15:34:11.819  WARN 8376 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/application/default": Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect
2019-03-11 15:34:11.826  INFO 8376 --- [           main] c.w.s.eureka.EurekaApplication           : No active profile set, falling back to default profiles: default
2019-03-11 15:34:11.837  INFO 8376 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@56b78e55: startup date [Mon Mar 11 15:34:11 CST 2019]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@446a1e84
2019-03-11 15:34:12.768  INFO 8376 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=299504f4-fcaf-37fd-a68b-b08b9784c17f
2019-03-11 15:34:12.782  INFO 8376 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-03-11 15:34:12.921  INFO 8376 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$bb70d5b8] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-11 15:34:13.223  INFO 8376 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8761 (http)
2019-03-11 15:34:13.248  INFO 8376 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-03-11 15:34:13.248  INFO 8376 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.31
2019-03-11 15:34:13.257  INFO 8376 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : Loaded APR based Apache Tomcat Native library [1.2.17] using APR version [1.6.3].
2019-03-11 15:34:13.258  INFO 8376 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2019-03-11 15:34:13.258  INFO 8376 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
2019-03-11 15:34:14.281  INFO 8376 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : OpenSSL successfully initialized [OpenSSL 1.0.2o  27 Mar 2018]
2019-03-11 15:34:14.395  INFO 8376 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-03-11 15:34:14.396  INFO 8376 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2558 ms
2019-03-11 15:34:14.615  WARN 8376 --- [ost-startStop-1] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2019-03-11 15:34:14.615  INFO 8376 --- [ost-startStop-1] 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.
2019-03-11 15:34:14.625  INFO 8376 --- [ost-startStop-1] c.netflix.config.DynamicPropertyFactory  : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration@46db3c34
2019-03-11 15:34:16.134  INFO 8376 --- [ost-startStop-1] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
2019-03-11 15:34:17.250  INFO 8376 --- [ost-startStop-1] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
2019-03-11 15:34:17.607  INFO 8376 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2019-03-11 15:34:17.608  INFO 8376 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-03-11 15:34:17.608  INFO 8376 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2019-03-11 15:34:17.608  INFO 8376 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2019-03-11 15:34:17.608  INFO 8376 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpTraceFilter' to: [/*]
2019-03-11 15:34:17.608  INFO 8376 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'webMvcMetricsFilter' to: [/*]
2019-03-11 15:34:17.608  INFO 8376 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'servletContainer' to urls: [/eureka/*]
2019-03-11 15:34:17.608  INFO 8376 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2019-03-11 15:34:17.684  INFO 8376 --- [ost-startStop-1] c.s.j.s.i.a.WebApplicationImpl           : Initiating Jersey application, version 'Jersey: 1.19.1 03/11/2016 02:08 PM'
2019-03-11 15:34:17.743  INFO 8376 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2019-03-11 15:34:17.745  INFO 8376 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2019-03-11 15:34:17.854  INFO 8376 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2019-03-11 15:34:17.854  INFO 8376 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2019-03-11 15:34:18.131  WARN 8376 --- [           main] o.s.c.n.a.ArchaiusAutoConfiguration      : No spring.application.name found, defaulting to 'application'
2019-03-11 15:34:18.132  WARN 8376 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2019-03-11 15:34:18.132  INFO 8376 --- [           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.
2019-03-11 15:34:18.203  INFO 8376 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-11 15:34:18.366  INFO 8376 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@56b78e55: startup date [Mon Mar 11 15:34:11 CST 2019]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@446a1e84
2019-03-11 15:34:18.428  INFO 8376 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2019-03-11 15:34:18.429  INFO 8376 --- [           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.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2019-03-11 15:34:18.432  INFO 8376 --- [           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)
2019-03-11 15:34:18.433  INFO 8376 --- [           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)
2019-03-11 15:34:18.454  INFO 8376 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-11 15:34:18.455  INFO 8376 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-11 15:34:18.765  INFO 8376 --- [           main] o.s.ui.freemarker.SpringTemplateLoader   : SpringTemplateLoader for FreeMarker: using resource loader [org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@56b78e55: startup date [Mon Mar 11 15:34:11 CST 2019]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@446a1e84] and template loader path [classpath:/templates/]
2019-03-11 15:34:18.766  INFO 8376 --- [           main] o.s.w.s.v.f.FreeMarkerConfigurer         : ClassTemplateLoader for Spring macros added to FreeMarker configuration
2019-03-11 15:34:18.941  INFO 8376 --- [           main] o.s.c.n.eureka.InstanceInfoFactory       : Setting initial instance status as: STARTING
2019-03-11 15:34:18.977  INFO 8376 --- [           main] com.netflix.discovery.DiscoveryClient    : Initializing Eureka in region us-east-1
2019-03-11 15:34:18.977  INFO 8376 --- [           main] com.netflix.discovery.DiscoveryClient    : Client configured to neither register nor query for data.
2019-03-11 15:34:18.988  INFO 8376 --- [           main] com.netflix.discovery.DiscoveryClient    : Discovery Client initialized at timestamp 1552289658987 with initial instances count: 0
2019-03-11 15:34:19.034  INFO 8376 --- [           main] c.n.eureka.DefaultEurekaServerContext    : Initializing ...
2019-03-11 15:34:19.036  WARN 8376 --- [           main] c.n.eureka.cluster.PeerEurekaNodes       : The replica size seems to be empty. Check the route 53 DNS Registry
2019-03-11 15:34:19.052  INFO 8376 --- [           main] c.n.e.registry.AbstractInstanceRegistry  : Finished initializing remote region registries. All known remote regions: []
2019-03-11 15:34:19.052  INFO 8376 --- [           main] c.n.eureka.DefaultEurekaServerContext    : Initialized
2019-03-11 15:34:19.071  INFO 8376 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 2 endpoint(s) beneath base path '/actuator'
2019-03-11 15:34:19.103  INFO 8376 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/health],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map)
2019-03-11 15:34:19.103  INFO 8376 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/info],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map)
2019-03-11 15:34:19.104  INFO 8376 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto protected java.util.Map> org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping.links(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2019-03-11 15:34:19.146  INFO 8376 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2019-03-11 15:34:19.154  INFO 8376 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'environmentManager' has been autodetected for JMX exposure
2019-03-11 15:34:19.155  INFO 8376 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'configurationPropertiesRebinder' has been autodetected for JMX exposure
2019-03-11 15:34:19.155  INFO 8376 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'refreshScope' has been autodetected for JMX exposure
2019-03-11 15:34:19.158  INFO 8376 --- [           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]
2019-03-11 15:34:19.165  INFO 8376 --- [           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]
2019-03-11 15:34:19.173  INFO 8376 --- [           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=56b78e55,type=ConfigurationPropertiesRebinder]
2019-03-11 15:34:19.183  INFO 8376 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
2019-03-11 15:34:19.183  INFO 8376 --- [           main] o.s.c.n.e.s.EurekaServiceRegistry        : Registering application unknown with eureka with status UP
2019-03-11 15:34:19.187  INFO 8376 --- [      Thread-13] o.s.c.n.e.server.EurekaServerBootstrap   : Setting the eureka configuration..
2019-03-11 15:34:19.188  INFO 8376 --- [      Thread-13] o.s.c.n.e.server.EurekaServerBootstrap   : Eureka data center value eureka.datacenter is not set, defaulting to default
2019-03-11 15:34:19.188  INFO 8376 --- [      Thread-13] o.s.c.n.e.server.EurekaServerBootstrap   : Eureka environment value eureka.environment is not set, defaulting to test
2019-03-11 15:34:19.201  INFO 8376 --- [      Thread-13] o.s.c.n.e.server.EurekaServerBootstrap   : isAws returned false
2019-03-11 15:34:19.202  INFO 8376 --- [      Thread-13] o.s.c.n.e.server.EurekaServerBootstrap   : Initialized server context
2019-03-11 15:34:19.202  INFO 8376 --- [      Thread-13] c.n.e.r.PeerAwareInstanceRegistryImpl    : Got 1 instances from neighboring DS node
2019-03-11 15:34:19.202  INFO 8376 --- [      Thread-13] c.n.e.r.PeerAwareInstanceRegistryImpl    : Renew threshold is: 1
2019-03-11 15:34:19.202  INFO 8376 --- [      Thread-13] c.n.e.r.PeerAwareInstanceRegistryImpl    : Changing status to UP
2019-03-11 15:34:19.209  INFO 8376 --- [      Thread-13] e.s.EurekaServerInitializerConfiguration : Started Eureka Server
2019-03-11 15:34:19.224  INFO 8376 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8761 (http) with context path ''
2019-03-11 15:34:19.225  INFO 8376 --- [           main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8761
2019-03-11 15:34:19.228  INFO 8376 --- [           main] c.w.s.eureka.EurekaApplication           : Started EurekaApplication in 11.524 seconds (JVM running for 11.977)
2019-03-11 15:34:19.231  INFO 8376 --- [           main] c.w.s.eureka.EurekaApplication           : application init success

浏览器地址输入http://localhost:8761/

spring-cloud-eureka服务发现注册中心及spring-cloud微服务_第1张图片

可以看到没有 实例注册到eureka上

下面我们新建一个client工程作为服务提供者注册到eureka(本身也是一个消费者这里我只用作提供者)spring-cloud微服务采用rest协议所以每一个微服务都是一个web工程

工程

com.wl.springcloud
client
1.0-SNAPSHOT

pom.xml   主要依赖spring-cloud-starter-netflix-eureka-client




  4.0.0

  com.wl.springcloud
  client
  1.0-SNAPSHOT

  client

  
    UTF-8
    1.8
    1.8
    2.0.0.RELEASE
    2.0.0.RELEASE
    2.0.3.RELEASE
    2.0.3.RELEASE
    com.wl.springcloud.client.ProviderApplication
  

  
    
      org.springframework.boot
      spring-boot-starter-web
      ${spring-boot-version}
    
    
      org.springframework.boot
      spring-boot-autoconfigure
      ${spring-boot-version}
    

    
    
      org.springframework.cloud
      spring-cloud-starter-netflix-eureka-client
      ${spring-cloud-eureka-client-version}
    
    
      
      
      
    
    
      org.springframework.cloud
      spring-cloud-starter-config
      ${spring-cloud-config-version}
    
    
      org.springframework.boot
      spring-boot-starter-test
      ${spring-boot-version}
      test
    
  

  
  
    
      
        org.springframework.boot
        spring-boot-maven-plugin
        ${spring-boot-version}
        
          ${MainClass}
          JAR
        
        
        
          
            
              repackage
            
          
        
      
      
      
        org.apache.maven.plugins
        maven-compiler-plugin
        3.1
        
          1.8
          1.8
        
      
    
    
    
      
        src/main/resources
        
          **/*.*
          *.*
        
      
      
        src/main/java
        
          **/*.*
          *.*
        
      
    
  

配置application.properties

server.port=8764
eureka.client.serviceUrl.defaultZone=http\://localhost\:8761/eureka/
spring.application.name=provider-client
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true

defaultZone是指定eureka服务器的地址,无论是注册还是发现服务都需要这个地址。spring.application.name是指定进行服务注册时该服务的名称

启动类

package com.wl.springcloud.client;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

/**
 * Created by Administrator on 2019/3/10.
 */
@SpringBootApplication(exclude = {
        DataSourceAutoConfiguration.class,
        DataSourceTransactionManagerAutoConfiguration.class,
        HibernateJpaAutoConfiguration.class,             //不使用数据库
        GsonAutoConfiguration.class                      //spring-boot2.0.0以上版本需要引入高版本的gson依赖,如果不引用gson依赖需要加此属性
},scanBasePackages = "com.wl")
@EnableDiscoveryClient
public class ProviderApplication {
    private static final Logger logger = LoggerFactory.getLogger(ProviderApplication.class);

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(ProviderApplication.class);
        app.setWebApplicationType(WebApplicationType.SERVLET);
        app.run(args);
        logger.info("application init success");
    }

    
}

注意EnableDiscoveryClient注解,只有加了这个注解eureka服务器才会注册此服务

下面新建一个controller作为提供接口

package com.wl.springcloud.client;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Administrator on 2019/3/10.
 */
@RestController
public class ProviderController {
    

    private Environment environment;

    @Autowired
    public ProviderController(Environment environment){
        this.environment = environment;
    }

    @RequestMapping("/provider")
    public String provider(){
        return "provider server port:" + environment.getProperty("server.port");
    }
    

}

启动此应用

"D:\Program Files\Java\jdk1.8.0_181\bin\java" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:63066,suspend=y,server=n -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dfile.encoding=UTF-8 -classpath "D:\Program Files\Java\jdk1.8.0_181\jre\lib\charsets.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\deploy.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\access-bridge-64.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\cldrdata.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\dnsns.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jaccess.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jfxrt.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\localedata.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\nashorn.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunec.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunjce_provider.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunmscapi.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunpkcs11.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\zipfs.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\javaws.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jce.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jfr.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jfxswt.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jsse.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\management-agent.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\plugin.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\resources.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\rt.jar;D:\workspace\wl\study\spring-cloud\client\target\classes;D:\maven\repo\org\springframework\boot\spring-boot-starter-web\2.0.3.RELEASE\spring-boot-starter-web-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter\2.0.3.RELEASE\spring-boot-starter-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-logging\2.0.3.RELEASE\spring-boot-starter-logging-2.0.3.RELEASE.jar;D:\maven\repo\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;D:\maven\repo\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;D:\maven\repo\org\apache\logging\log4j\log4j-to-slf4j\2.10.0\log4j-to-slf4j-2.10.0.jar;D:\maven\repo\org\apache\logging\log4j\log4j-api\2.10.0\log4j-api-2.10.0.jar;D:\maven\repo\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;D:\maven\repo\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;D:\maven\repo\org\yaml\snakeyaml\1.19\snakeyaml-1.19.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-json\2.0.3.RELEASE\spring-boot-starter-json-2.0.3.RELEASE.jar;D:\maven\repo\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.9.6\jackson-datatype-jdk8-2.9.6.jar;D:\maven\repo\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.9.6\jackson-datatype-jsr310-2.9.6.jar;D:\maven\repo\com\fasterxml\jackson\module\jackson-module-parameter-names\2.9.6\jackson-module-parameter-names-2.9.6.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-tomcat\2.0.3.RELEASE\spring-boot-starter-tomcat-2.0.3.RELEASE.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-core\8.5.31\tomcat-embed-core-8.5.31.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-el\8.5.31\tomcat-embed-el-8.5.31.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-websocket\8.5.31\tomcat-embed-websocket-8.5.31.jar;D:\maven\repo\org\hibernate\validator\hibernate-validator\6.0.10.Final\hibernate-validator-6.0.10.Final.jar;D:\maven\repo\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;D:\maven\repo\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;D:\maven\repo\com\fasterxml\classmate\1.3.4\classmate-1.3.4.jar;D:\maven\repo\org\springframework\spring-web\5.0.7.RELEASE\spring-web-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\spring-beans\5.0.7.RELEASE\spring-beans-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\spring-webmvc\5.0.7.RELEASE\spring-webmvc-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\spring-aop\5.0.7.RELEASE\spring-aop-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\spring-context\5.0.7.RELEASE\spring-context-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\spring-expression\5.0.7.RELEASE\spring-expression-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-autoconfigure\2.0.3.RELEASE\spring-boot-autoconfigure-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot\2.0.3.RELEASE\spring-boot-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter-netflix-eureka-client\2.0.3.RELEASE\spring-cloud-starter-netflix-eureka-client-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter\2.0.3.RELEASE\spring-cloud-starter-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-context\2.0.3.RELEASE\spring-cloud-context-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\security\spring-security-crypto\5.0.11.RELEASE\spring-security-crypto-5.0.11.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-commons\2.0.3.RELEASE\spring-cloud-commons-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\security\spring-security-rsa\1.0.7.RELEASE\spring-security-rsa-1.0.7.RELEASE.jar;D:\maven\repo\org\bouncycastle\bcpkix-jdk15on\1.60\bcpkix-jdk15on-1.60.jar;D:\maven\repo\org\bouncycastle\bcprov-jdk15on\1.60\bcprov-jdk15on-1.60.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-netflix-core\2.0.3.RELEASE\spring-cloud-netflix-core-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-aop\2.0.8.RELEASE\spring-boot-starter-aop-2.0.8.RELEASE.jar;D:\maven\repo\org\aspectj\aspectjweaver\1.8.13\aspectjweaver-1.8.13.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-netflix-eureka-client\2.0.3.RELEASE\spring-cloud-netflix-eureka-client-2.0.3.RELEASE.jar;D:\maven\repo\com\netflix\eureka\eureka-client\1.9.3\eureka-client-1.9.3.jar;D:\maven\repo\org\codehaus\jettison\jettison\1.3.7\jettison-1.3.7.jar;D:\maven\repo\stax\stax-api\1.0.1\stax-api-1.0.1.jar;D:\maven\repo\com\netflix\netflix-commons\netflix-eventbus\0.3.0\netflix-eventbus-0.3.0.jar;D:\maven\repo\com\netflix\netflix-commons\netflix-infix\0.3.0\netflix-infix-0.3.0.jar;D:\maven\repo\commons-jxpath\commons-jxpath\1.3\commons-jxpath-1.3.jar;D:\maven\repo\joda-time\joda-time\2.3\joda-time-2.3.jar;D:\maven\repo\org\antlr\antlr-runtime\3.4\antlr-runtime-3.4.jar;D:\maven\repo\org\antlr\stringtemplate\3.2.1\stringtemplate-3.2.1.jar;D:\maven\repo\antlr\antlr\2.7.7\antlr-2.7.7.jar;D:\maven\repo\com\google\code\gson\gson\2.1\gson-2.1.jar;D:\maven\repo\org\apache\commons\commons-math\2.2\commons-math-2.2.jar;D:\maven\repo\com\netflix\archaius\archaius-core\0.7.6\archaius-core-0.7.6.jar;D:\maven\repo\com\google\guava\guava\16.0\guava-16.0.jar;D:\maven\repo\javax\ws\rs\jsr311-api\1.1.1\jsr311-api-1.1.1.jar;D:\maven\repo\com\netflix\servo\servo-core\0.12.21\servo-core-0.12.21.jar;D:\maven\repo\com\sun\jersey\jersey-core\1.19.1\jersey-core-1.19.1.jar;D:\maven\repo\com\sun\jersey\jersey-client\1.19.1\jersey-client-1.19.1.jar;D:\maven\repo\com\sun\jersey\contribs\jersey-apache-client4\1.19.1\jersey-apache-client4-1.19.1.jar;D:\maven\repo\org\apache\httpcomponents\httpclient\4.5.3\httpclient-4.5.3.jar;D:\maven\repo\org\apache\httpcomponents\httpcore\4.4.6\httpcore-4.4.6.jar;D:\maven\repo\commons-codec\commons-codec\1.9\commons-codec-1.9.jar;D:\maven\repo\com\google\inject\guice\4.1.0\guice-4.1.0.jar;D:\maven\repo\javax\inject\javax.inject\1\javax.inject-1.jar;D:\maven\repo\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;D:\maven\repo\com\github\vlsi\compactmap\compactmap\1.2.1\compactmap-1.2.1.jar;D:\maven\repo\com\github\andrewoma\dexx\dexx-collections\0.2\dexx-collections-0.2.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-annotations\2.9.4\jackson-annotations-2.9.4.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-core\2.9.4\jackson-core-2.9.4.jar;D:\maven\repo\com\netflix\eureka\eureka-core\1.9.3\eureka-core-1.9.3.jar;D:\maven\repo\org\codehaus\woodstox\woodstox-core-asl\4.4.1\woodstox-core-asl-4.4.1.jar;D:\maven\repo\javax\xml\stream\stax-api\1.0-2\stax-api-1.0-2.jar;D:\maven\repo\org\codehaus\woodstox\stax2-api\3.1.4\stax2-api-3.1.4.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter-netflix-archaius\2.0.3.RELEASE\spring-cloud-starter-netflix-archaius-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-netflix-ribbon\2.0.3.RELEASE\spring-cloud-netflix-ribbon-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-netflix-archaius\2.0.3.RELEASE\spring-cloud-netflix-archaius-2.0.3.RELEASE.jar;D:\maven\repo\commons-configuration\commons-configuration\1.8\commons-configuration-1.8.jar;D:\maven\repo\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter-netflix-ribbon\2.0.3.RELEASE\spring-cloud-starter-netflix-ribbon-2.0.3.RELEASE.jar;D:\maven\repo\com\netflix\ribbon\ribbon\2.2.5\ribbon-2.2.5.jar;D:\maven\repo\com\netflix\ribbon\ribbon-transport\2.2.5\ribbon-transport-2.2.5.jar;D:\maven\repo\io\reactivex\rxnetty-contexts\0.4.9\rxnetty-contexts-0.4.9.jar;D:\maven\repo\io\reactivex\rxnetty-servo\0.4.9\rxnetty-servo-0.4.9.jar;D:\maven\repo\com\netflix\hystrix\hystrix-core\1.4.3\hystrix-core-1.4.3.jar;D:\maven\repo\io\reactivex\rxnetty\0.4.9\rxnetty-0.4.9.jar;D:\maven\repo\com\netflix\ribbon\ribbon-core\2.2.5\ribbon-core-2.2.5.jar;D:\maven\repo\com\netflix\ribbon\ribbon-httpclient\2.2.5\ribbon-httpclient-2.2.5.jar;D:\maven\repo\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;D:\maven\repo\com\netflix\netflix-commons\netflix-commons-util\0.1.1\netflix-commons-util-0.1.1.jar;D:\maven\repo\com\netflix\ribbon\ribbon-loadbalancer\2.2.5\ribbon-loadbalancer-2.2.5.jar;D:\maven\repo\com\netflix\netflix-commons\netflix-statistics\0.1.1\netflix-statistics-0.1.1.jar;D:\maven\repo\io\reactivex\rxjava\1.2.0\rxjava-1.2.0.jar;D:\maven\repo\com\netflix\ribbon\ribbon-eureka\2.2.5\ribbon-eureka-2.2.5.jar;D:\maven\repo\org\slf4j\slf4j-api\1.7.12\slf4j-api-1.7.12.jar;D:\maven\repo\com\thoughtworks\xstream\xstream\1.4.10\xstream-1.4.10.jar;D:\maven\repo\xmlpull\xmlpull\1.1.3.1\xmlpull-1.1.3.1.jar;D:\maven\repo\xpp3\xpp3_min\1.1.4c\xpp3_min-1.1.4c.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter-config\2.0.0.RELEASE\spring-cloud-starter-config-2.0.0.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-config-client\2.0.0.RELEASE\spring-cloud-config-client-2.0.0.RELEASE.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-databind\2.9.6\jackson-databind-2.9.6.jar;D:\maven\repo\org\springframework\spring-core\5.0.7.RELEASE\spring-core-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\spring-jcl\5.0.7.RELEASE\spring-jcl-5.0.7.RELEASE.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2017.1.6\lib\idea_rt.jar" com.wl.springcloud.client.ProviderApplication
Connected to the target VM, address: '127.0.0.1:63066', transport: 'socket'
2019-03-11 15:54:32.290  INFO 7448 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@1500b2f3: startup date [Mon Mar 11 15:54:32 CST 2019]; root of context hierarchy
2019-03-11 15:54:32.469  INFO 7448 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-03-11 15:54:32.494  INFO 7448 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$2d7e2a28] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

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

2019-03-11 15:54:33.686  INFO 7448 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2019-03-11 15:54:34.758  INFO 7448 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8888. Will be trying the next url if available
2019-03-11 15:54:34.759  WARN 7448 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/provider-client/default": Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect
2019-03-11 15:54:34.760  INFO 7448 --- [           main] c.w.s.client.ProviderApplication         : No active profile set, falling back to default profiles: default
2019-03-11 15:54:34.770  INFO 7448 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@297ea53a: startup date [Mon Mar 11 15:54:34 CST 2019]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@1500b2f3
2019-03-11 15:54:35.129  INFO 7448 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=aed0e163-d024-3b1c-b7d4-182b8430f378
2019-03-11 15:54:35.140  INFO 7448 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-03-11 15:54:35.200  INFO 7448 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$2d7e2a28] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-11 15:54:35.417  INFO 7448 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8764 (http)
2019-03-11 15:54:35.431  INFO 7448 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-03-11 15:54:35.431  INFO 7448 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.31
2019-03-11 15:54:35.434  INFO 7448 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : Loaded APR based Apache Tomcat Native library [1.2.17] using APR version [1.6.3].
2019-03-11 15:54:35.434  INFO 7448 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2019-03-11 15:54:35.435  INFO 7448 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
2019-03-11 15:54:36.469  INFO 7448 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : OpenSSL successfully initialized [OpenSSL 1.0.2o  27 Mar 2018]
2019-03-11 15:54:36.565  INFO 7448 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-03-11 15:54:36.565  INFO 7448 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1795 ms
2019-03-11 15:54:36.673  INFO 7448 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2019-03-11 15:54:36.677  INFO 7448 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2019-03-11 15:54:36.678  INFO 7448 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-03-11 15:54:36.678  INFO 7448 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2019-03-11 15:54:36.678  INFO 7448 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2019-03-11 15:54:36.738  WARN 7448 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2019-03-11 15:54:36.738  INFO 7448 --- [           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.
2019-03-11 15:54:36.741  WARN 7448 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2019-03-11 15:54:36.741  INFO 7448 --- [           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.
2019-03-11 15:54:36.809  INFO 7448 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-11 15:54:36.962  INFO 7448 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@297ea53a: startup date [Mon Mar 11 15:54:34 CST 2019]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@1500b2f3
2019-03-11 15:54:37.005  INFO 7448 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/provider]}" onto public java.lang.String com.wl.springcloud.client.ProviderController.provider()
2019-03-11 15:54:37.009  INFO 7448 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2019-03-11 15:54:37.009  INFO 7448 --- [           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.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2019-03-11 15:54:37.032  INFO 7448 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-11 15:54:37.032  INFO 7448 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-11 15:54:38.322  INFO 7448 --- [           main] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
2019-03-11 15:54:39.421  INFO 7448 --- [           main] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
2019-03-11 15:54:39.538  INFO 7448 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2019-03-11 15:54:39.544  INFO 7448 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'configurationPropertiesRebinder' has been autodetected for JMX exposure
2019-03-11 15:54:39.544  INFO 7448 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'environmentManager' has been autodetected for JMX exposure
2019-03-11 15:54:39.544  INFO 7448 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'refreshScope' has been autodetected for JMX exposure
2019-03-11 15:54:39.547  INFO 7448 --- [           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]
2019-03-11 15:54:39.555  INFO 7448 --- [           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]
2019-03-11 15:54:39.563  INFO 7448 --- [           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=297ea53a,type=ConfigurationPropertiesRebinder]
2019-03-11 15:54:39.569  INFO 7448 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
2019-03-11 15:54:39.579  INFO 7448 --- [           main] o.s.c.n.eureka.InstanceInfoFactory       : Setting initial instance status as: STARTING
2019-03-11 15:54:39.607  INFO 7448 --- [           main] com.netflix.discovery.DiscoveryClient    : Initializing Eureka in region us-east-1
2019-03-11 15:54:39.849  INFO 7448 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2019-03-11 15:54:39.849  INFO 7448 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2019-03-11 15:54:39.929  INFO 7448 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2019-03-11 15:54:39.929  INFO 7448 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2019-03-11 15:54:40.082  INFO 7448 --- [           main] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2019-03-11 15:54:40.138  INFO 7448 --- [           main] com.netflix.discovery.DiscoveryClient    : Disable delta property : false
2019-03-11 15:54:40.138  INFO 7448 --- [           main] com.netflix.discovery.DiscoveryClient    : Single vip registry refresh property : null
2019-03-11 15:54:40.138  INFO 7448 --- [           main] com.netflix.discovery.DiscoveryClient    : Force full registry fetch : false
2019-03-11 15:54:40.138  INFO 7448 --- [           main] com.netflix.discovery.DiscoveryClient    : Application is null : false
2019-03-11 15:54:40.138  INFO 7448 --- [           main] com.netflix.discovery.DiscoveryClient    : Registered Applications size is zero : true
2019-03-11 15:54:40.138  INFO 7448 --- [           main] com.netflix.discovery.DiscoveryClient    : Application version is -1: true
2019-03-11 15:54:40.138  INFO 7448 --- [           main] com.netflix.discovery.DiscoveryClient    : Getting all instance registry info from the eureka server
2019-03-11 15:54:40.246  INFO 7448 --- [           main] com.netflix.discovery.DiscoveryClient    : The response status is 200
2019-03-11 15:54:40.248  INFO 7448 --- [           main] com.netflix.discovery.DiscoveryClient    : Starting heartbeat executor: renew interval is: 30
2019-03-11 15:54:40.249  INFO 7448 --- [           main] c.n.discovery.InstanceInfoReplicator     : InstanceInfoReplicator onDemand update allowed rate per min is 4
2019-03-11 15:54:40.252  INFO 7448 --- [           main] com.netflix.discovery.DiscoveryClient    : Discovery Client initialized at timestamp 1552290880251 with initial instances count: 0
2019-03-11 15:54:40.255  INFO 7448 --- [           main] o.s.c.n.e.s.EurekaServiceRegistry        : Registering application PROVIDER-CLIENT with eureka with status UP
2019-03-11 15:54:40.256  INFO 7448 --- [           main] com.netflix.discovery.DiscoveryClient    : Saw local status change event StatusChangeEvent [timestamp=1552290880256, current=UP, previous=STARTING]
2019-03-11 15:54:40.257  INFO 7448 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_PROVIDER-CLIENT/localhost:provider-client:8764: registering service...
2019-03-11 15:54:40.285  INFO 7448 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8764 (http) with context path ''
2019-03-11 15:54:40.286  INFO 7448 --- [           main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8764
2019-03-11 15:54:40.288  INFO 7448 --- [           main] c.w.s.client.ProviderApplication         : Started ProviderApplication in 9.38 seconds (JVM running for 9.72)
2019-03-11 15:54:40.289  INFO 7448 --- [           main] c.w.s.client.ProviderApplication         : application init success
2019-03-11 15:54:40.328  INFO 7448 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_PROVIDER-CLIENT/localhost:provider-client:8764 - registration status: 204

刷新 http://localhost:8761/

spring-cloud-eureka服务发现注册中心及spring-cloud微服务_第2张图片

 现在我们需要一个消费者应用来消费这个服务(spring-cloud为服务采用rest协议,所以消费者与提供者之间使用RestTemplate通信)

新建工程consume-client(与上面的client一样)

com.wl.springcloud
consume-client
1.0-SNAPSHOT

pom.xml




  4.0.0

  com.wl.springcloud
  consume-client
  1.0-SNAPSHOT

  consume-client
  
  http://www.example.com
  
    UTF-8
    1.8
    1.8
    2.0.0.RELEASE
    2.0.0.RELEASE
    2.0.3.RELEASE
    2.0.3.RELEASE
    com.wl.springcloud.comsumeclient.ConsumeApplication
  

  
    
      org.springframework.boot
      spring-boot-starter-web
      ${spring-boot-version}
    
    
      org.springframework.boot
      spring-boot-autoconfigure
      ${spring-boot-version}
    

    
    
      org.springframework.cloud
      spring-cloud-starter-netflix-eureka-client
      ${spring-cloud-eureka-client-version}
    

    
      org.springframework.cloud
      spring-cloud-starter-netflix-hystrix
      2.0.3.RELEASE
    
    
    
    
    
    
    
      org.springframework.cloud
      spring-cloud-starter-config
      ${spring-cloud-config-version}
    
    
      org.springframework.boot
      spring-boot-starter-test
      ${spring-boot-version}
      test
    
  

  
  
    
      
        org.springframework.boot
        spring-boot-maven-plugin
        ${spring-boot-version}
        
          ${MainClass}
          JAR
        
        
        
          
            
              repackage
            
          
        
      
      
      
        org.apache.maven.plugins
        maven-compiler-plugin
        3.1
        
          1.8
          1.8
        
      
    
    
    
      
        src/main/resources
        
          **/*.*
          *.*
        
      
      
        src/main/java
        
          **/*.*
          *.*
        
      
    
  


application.properties

server.port=8763
eureka.client.serviceUrl.defaultZone=http\://localhost\:8761/eureka/
spring.application.name=consume-client
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true

启动类

package com.wl.springcloud.comsumeclient;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * Created by Administrator on 2019/3/11.
 */
@SpringBootApplication(exclude = {
        DataSourceAutoConfiguration.class,
        DataSourceTransactionManagerAutoConfiguration.class,
        HibernateJpaAutoConfiguration.class,             //不使用数据库
        GsonAutoConfiguration.class                      //spring-boot2.0.0以上版本需要引入高版本的gson依赖,如果不引用gson依赖需要加此属性
},scanBasePackages = "com.wl")
@EnableDiscoveryClient
public class ConsumeApplication {
    private static final Logger logger = LoggerFactory.getLogger(ConsumeApplication.class);

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(ConsumeApplication.class);
        app.setWebApplicationType(WebApplicationType.SERVLET);
        app.run(args);
        logger.info("application init success");
    }

    @LoadBalanced
    @Bean
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }

}

consumeController

package com.wl.springcloud.comsumeclient;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * Created by Administrator on 2019/3/11.
 */
@RestController
public class ConsumeController {

    private RestTemplate restTemplate;

    @Autowired
    public ConsumeController(RestTemplate restTemplate){
        this.restTemplate = restTemplate;
    }

    private static final String SERVER_NAME = "provider-client";
    
    @RequestMapping("/consume")
    public String consume(){
        String provider = restTemplate.getForObject("http://" + SERVER_NAME +"/provider",String.class);
        return "consume - " + provider;
    }
    

}

注意SERVER_NAME为上面client工程application.properties中的spring.application.name

可以看到使用restTemplate只用指定协议+服务名称+对应的路径就可以访问spring-cloud微服务(与直接localhost:8764/provider不同,不用指定端口和host)

启动应用

"D:\Program Files\Java\jdk1.8.0_181\bin\java" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:63391,suspend=y,server=n -Dfile.encoding=UTF-8 -classpath "D:\Program Files\Java\jdk1.8.0_181\jre\lib\charsets.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\deploy.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\access-bridge-64.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\cldrdata.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\dnsns.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jaccess.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jfxrt.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\localedata.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\nashorn.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunec.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunjce_provider.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunmscapi.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunpkcs11.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\zipfs.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\javaws.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jce.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jfr.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jfxswt.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jsse.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\management-agent.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\plugin.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\resources.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\rt.jar;D:\workspace\wl\study\spring-cloud\consume-client\target\classes;D:\maven\repo\org\springframework\boot\spring-boot-starter-web\2.0.3.RELEASE\spring-boot-starter-web-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter\2.0.3.RELEASE\spring-boot-starter-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-logging\2.0.3.RELEASE\spring-boot-starter-logging-2.0.3.RELEASE.jar;D:\maven\repo\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;D:\maven\repo\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;D:\maven\repo\org\apache\logging\log4j\log4j-to-slf4j\2.10.0\log4j-to-slf4j-2.10.0.jar;D:\maven\repo\org\apache\logging\log4j\log4j-api\2.10.0\log4j-api-2.10.0.jar;D:\maven\repo\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;D:\maven\repo\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;D:\maven\repo\org\yaml\snakeyaml\1.19\snakeyaml-1.19.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-json\2.0.3.RELEASE\spring-boot-starter-json-2.0.3.RELEASE.jar;D:\maven\repo\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.9.6\jackson-datatype-jdk8-2.9.6.jar;D:\maven\repo\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.9.6\jackson-datatype-jsr310-2.9.6.jar;D:\maven\repo\com\fasterxml\jackson\module\jackson-module-parameter-names\2.9.6\jackson-module-parameter-names-2.9.6.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-tomcat\2.0.3.RELEASE\spring-boot-starter-tomcat-2.0.3.RELEASE.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-core\8.5.31\tomcat-embed-core-8.5.31.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-el\8.5.31\tomcat-embed-el-8.5.31.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-websocket\8.5.31\tomcat-embed-websocket-8.5.31.jar;D:\maven\repo\org\hibernate\validator\hibernate-validator\6.0.10.Final\hibernate-validator-6.0.10.Final.jar;D:\maven\repo\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;D:\maven\repo\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;D:\maven\repo\com\fasterxml\classmate\1.3.4\classmate-1.3.4.jar;D:\maven\repo\org\springframework\spring-web\5.0.7.RELEASE\spring-web-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\spring-beans\5.0.7.RELEASE\spring-beans-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\spring-webmvc\5.0.7.RELEASE\spring-webmvc-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\spring-aop\5.0.7.RELEASE\spring-aop-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\spring-context\5.0.7.RELEASE\spring-context-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\spring-expression\5.0.7.RELEASE\spring-expression-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-autoconfigure\2.0.3.RELEASE\spring-boot-autoconfigure-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot\2.0.3.RELEASE\spring-boot-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter-netflix-eureka-client\2.0.3.RELEASE\spring-cloud-starter-netflix-eureka-client-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter\2.0.3.RELEASE\spring-cloud-starter-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-context\2.0.3.RELEASE\spring-cloud-context-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\security\spring-security-crypto\5.0.11.RELEASE\spring-security-crypto-5.0.11.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-commons\2.0.3.RELEASE\spring-cloud-commons-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\security\spring-security-rsa\1.0.7.RELEASE\spring-security-rsa-1.0.7.RELEASE.jar;D:\maven\repo\org\bouncycastle\bcpkix-jdk15on\1.60\bcpkix-jdk15on-1.60.jar;D:\maven\repo\org\bouncycastle\bcprov-jdk15on\1.60\bcprov-jdk15on-1.60.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-netflix-core\2.0.3.RELEASE\spring-cloud-netflix-core-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-aop\2.0.8.RELEASE\spring-boot-starter-aop-2.0.8.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-netflix-eureka-client\2.0.3.RELEASE\spring-cloud-netflix-eureka-client-2.0.3.RELEASE.jar;D:\maven\repo\com\netflix\eureka\eureka-client\1.9.3\eureka-client-1.9.3.jar;D:\maven\repo\org\codehaus\jettison\jettison\1.3.7\jettison-1.3.7.jar;D:\maven\repo\stax\stax-api\1.0.1\stax-api-1.0.1.jar;D:\maven\repo\com\netflix\netflix-commons\netflix-eventbus\0.3.0\netflix-eventbus-0.3.0.jar;D:\maven\repo\com\netflix\netflix-commons\netflix-infix\0.3.0\netflix-infix-0.3.0.jar;D:\maven\repo\commons-jxpath\commons-jxpath\1.3\commons-jxpath-1.3.jar;D:\maven\repo\joda-time\joda-time\2.3\joda-time-2.3.jar;D:\maven\repo\org\antlr\antlr-runtime\3.4\antlr-runtime-3.4.jar;D:\maven\repo\org\antlr\stringtemplate\3.2.1\stringtemplate-3.2.1.jar;D:\maven\repo\antlr\antlr\2.7.7\antlr-2.7.7.jar;D:\maven\repo\com\google\code\gson\gson\2.1\gson-2.1.jar;D:\maven\repo\org\apache\commons\commons-math\2.2\commons-math-2.2.jar;D:\maven\repo\com\netflix\archaius\archaius-core\0.7.6\archaius-core-0.7.6.jar;D:\maven\repo\javax\ws\rs\jsr311-api\1.1.1\jsr311-api-1.1.1.jar;D:\maven\repo\com\netflix\servo\servo-core\0.12.21\servo-core-0.12.21.jar;D:\maven\repo\com\sun\jersey\jersey-core\1.19.1\jersey-core-1.19.1.jar;D:\maven\repo\com\sun\jersey\jersey-client\1.19.1\jersey-client-1.19.1.jar;D:\maven\repo\com\sun\jersey\contribs\jersey-apache-client4\1.19.1\jersey-apache-client4-1.19.1.jar;D:\maven\repo\org\apache\httpcomponents\httpclient\4.5.3\httpclient-4.5.3.jar;D:\maven\repo\org\apache\httpcomponents\httpcore\4.4.6\httpcore-4.4.6.jar;D:\maven\repo\commons-codec\commons-codec\1.9\commons-codec-1.9.jar;D:\maven\repo\com\google\inject\guice\4.1.0\guice-4.1.0.jar;D:\maven\repo\javax\inject\javax.inject\1\javax.inject-1.jar;D:\maven\repo\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;D:\maven\repo\com\github\vlsi\compactmap\compactmap\1.2.1\compactmap-1.2.1.jar;D:\maven\repo\com\github\andrewoma\dexx\dexx-collections\0.2\dexx-collections-0.2.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-annotations\2.9.4\jackson-annotations-2.9.4.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-core\2.9.4\jackson-core-2.9.4.jar;D:\maven\repo\com\netflix\eureka\eureka-core\1.9.3\eureka-core-1.9.3.jar;D:\maven\repo\org\codehaus\woodstox\woodstox-core-asl\4.4.1\woodstox-core-asl-4.4.1.jar;D:\maven\repo\javax\xml\stream\stax-api\1.0-2\stax-api-1.0-2.jar;D:\maven\repo\org\codehaus\woodstox\stax2-api\3.1.4\stax2-api-3.1.4.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter-netflix-archaius\2.0.3.RELEASE\spring-cloud-starter-netflix-archaius-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-netflix-archaius\2.0.3.RELEASE\spring-cloud-netflix-archaius-2.0.3.RELEASE.jar;D:\maven\repo\commons-configuration\commons-configuration\1.8\commons-configuration-1.8.jar;D:\maven\repo\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter-netflix-ribbon\2.0.3.RELEASE\spring-cloud-starter-netflix-ribbon-2.0.3.RELEASE.jar;D:\maven\repo\com\netflix\ribbon\ribbon\2.2.5\ribbon-2.2.5.jar;D:\maven\repo\com\netflix\ribbon\ribbon-transport\2.2.5\ribbon-transport-2.2.5.jar;D:\maven\repo\io\reactivex\rxnetty-contexts\0.4.9\rxnetty-contexts-0.4.9.jar;D:\maven\repo\io\reactivex\rxnetty-servo\0.4.9\rxnetty-servo-0.4.9.jar;D:\maven\repo\io\reactivex\rxnetty\0.4.9\rxnetty-0.4.9.jar;D:\maven\repo\com\netflix\ribbon\ribbon-core\2.2.5\ribbon-core-2.2.5.jar;D:\maven\repo\com\netflix\ribbon\ribbon-httpclient\2.2.5\ribbon-httpclient-2.2.5.jar;D:\maven\repo\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;D:\maven\repo\com\netflix\netflix-commons\netflix-commons-util\0.1.1\netflix-commons-util-0.1.1.jar;D:\maven\repo\com\netflix\ribbon\ribbon-loadbalancer\2.2.5\ribbon-loadbalancer-2.2.5.jar;D:\maven\repo\com\netflix\netflix-commons\netflix-statistics\0.1.1\netflix-statistics-0.1.1.jar;D:\maven\repo\io\reactivex\rxjava\1.2.0\rxjava-1.2.0.jar;D:\maven\repo\com\netflix\ribbon\ribbon-eureka\2.2.5\ribbon-eureka-2.2.5.jar;D:\maven\repo\org\slf4j\slf4j-api\1.7.12\slf4j-api-1.7.12.jar;D:\maven\repo\com\thoughtworks\xstream\xstream\1.4.10\xstream-1.4.10.jar;D:\maven\repo\xmlpull\xmlpull\1.1.3.1\xmlpull-1.1.3.1.jar;D:\maven\repo\xpp3\xpp3_min\1.1.4c\xpp3_min-1.1.4c.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter-netflix-hystrix\2.0.3.RELEASE\spring-cloud-starter-netflix-hystrix-2.0.3.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-netflix-ribbon\2.0.3.RELEASE\spring-cloud-netflix-ribbon-2.0.3.RELEASE.jar;D:\maven\repo\com\netflix\hystrix\hystrix-core\1.5.18\hystrix-core-1.5.18.jar;D:\maven\repo\org\hdrhistogram\HdrHistogram\2.1.9\HdrHistogram-2.1.9.jar;D:\maven\repo\com\netflix\hystrix\hystrix-serialization\1.5.18\hystrix-serialization-1.5.18.jar;D:\maven\repo\com\fasterxml\jackson\module\jackson-module-afterburner\2.7.5\jackson-module-afterburner-2.7.5.jar;D:\maven\repo\com\netflix\hystrix\hystrix-metrics-event-stream\1.5.18\hystrix-metrics-event-stream-1.5.18.jar;D:\maven\repo\com\netflix\hystrix\hystrix-javanica\1.5.18\hystrix-javanica-1.5.18.jar;D:\maven\repo\org\apache\commons\commons-lang3\3.1\commons-lang3-3.1.jar;D:\maven\repo\org\ow2\asm\asm\5.0.4\asm-5.0.4.jar;D:\maven\repo\org\aspectj\aspectjweaver\1.8.6\aspectjweaver-1.8.6.jar;D:\maven\repo\com\google\guava\guava\15.0\guava-15.0.jar;D:\maven\repo\io\reactivex\rxjava-reactive-streams\1.2.1\rxjava-reactive-streams-1.2.1.jar;D:\maven\repo\org\reactivestreams\reactive-streams\1.0.0\reactive-streams-1.0.0.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter-config\2.0.0.RELEASE\spring-cloud-starter-config-2.0.0.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-config-client\2.0.0.RELEASE\spring-cloud-config-client-2.0.0.RELEASE.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-databind\2.9.6\jackson-databind-2.9.6.jar;D:\maven\repo\org\springframework\spring-core\5.0.7.RELEASE\spring-core-5.0.7.RELEASE.jar;D:\maven\repo\org\springframework\spring-jcl\5.0.7.RELEASE\spring-jcl-5.0.7.RELEASE.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2017.1.6\lib\idea_rt.jar" com.wl.springcloud.comsumeclient.ConsumeApplication
Connected to the target VM, address: '127.0.0.1:63391', transport: 'socket'
2019-03-11 16:06:49.073  INFO 3020 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@22d7b4f8: startup date [Mon Mar 11 16:06:49 CST 2019]; root of context hierarchy
2019-03-11 16:06:49.287  INFO 3020 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-03-11 16:06:49.312  INFO 3020 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$443a41d2] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

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

2019-03-11 16:06:50.540  INFO 3020 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2019-03-11 16:06:51.628  INFO 3020 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8888. Will be trying the next url if available
2019-03-11 16:06:51.628  WARN 3020 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/consume-client/default": Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect
2019-03-11 16:06:51.630  INFO 3020 --- [           main] c.w.s.comsumeclient.ConsumeApplication   : No active profile set, falling back to default profiles: default
2019-03-11 16:06:51.640  INFO 3020 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@341a8659: startup date [Mon Mar 11 16:06:51 CST 2019]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@22d7b4f8
2019-03-11 16:06:52.066  INFO 3020 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=d14c323c-7089-3747-b044-bf025cfa863b
2019-03-11 16:06:52.078  INFO 3020 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-03-11 16:06:52.150  INFO 3020 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$443a41d2] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-11 16:06:52.424  INFO 3020 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8763 (http)
2019-03-11 16:06:52.446  INFO 3020 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-03-11 16:06:52.446  INFO 3020 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.31
2019-03-11 16:06:52.454  INFO 3020 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : Loaded APR based Apache Tomcat Native library [1.2.17] using APR version [1.6.3].
2019-03-11 16:06:52.454  INFO 3020 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2019-03-11 16:06:52.454  INFO 3020 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
2019-03-11 16:06:53.483  INFO 3020 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : OpenSSL successfully initialized [OpenSSL 1.0.2o  27 Mar 2018]
2019-03-11 16:06:53.637  INFO 3020 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-03-11 16:06:53.637  INFO 3020 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1997 ms
2019-03-11 16:06:53.748  INFO 3020 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2019-03-11 16:06:53.752  INFO 3020 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2019-03-11 16:06:53.752  INFO 3020 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-03-11 16:06:53.752  INFO 3020 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2019-03-11 16:06:53.752  INFO 3020 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2019-03-11 16:06:53.814  WARN 3020 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2019-03-11 16:06:53.815  INFO 3020 --- [           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.
2019-03-11 16:06:53.819  WARN 3020 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2019-03-11 16:06:53.819  INFO 3020 --- [           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.
2019-03-11 16:06:53.896  INFO 3020 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-11 16:06:54.067  INFO 3020 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@341a8659: startup date [Mon Mar 11 16:06:51 CST 2019]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@22d7b4f8
2019-03-11 16:06:54.123  INFO 3020 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/consume]}" onto public java.lang.String com.wl.springcloud.comsumeclient.ConsumeController.consume()
2019-03-11 16:06:54.127  INFO 3020 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2019-03-11 16:06:54.127  INFO 3020 --- [           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.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2019-03-11 16:06:54.152  INFO 3020 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-11 16:06:54.152  INFO 3020 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-11 16:06:55.523  INFO 3020 --- [           main] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
2019-03-11 16:06:56.629  INFO 3020 --- [           main] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
2019-03-11 16:06:56.762  INFO 3020 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2019-03-11 16:06:56.770  INFO 3020 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'configurationPropertiesRebinder' has been autodetected for JMX exposure
2019-03-11 16:06:56.770  INFO 3020 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'environmentManager' has been autodetected for JMX exposure
2019-03-11 16:06:56.770  INFO 3020 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'refreshScope' has been autodetected for JMX exposure
2019-03-11 16:06:56.773  INFO 3020 --- [           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]
2019-03-11 16:06:56.784  INFO 3020 --- [           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]
2019-03-11 16:06:56.793  INFO 3020 --- [           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=341a8659,type=ConfigurationPropertiesRebinder]
2019-03-11 16:06:56.804  INFO 3020 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
2019-03-11 16:06:56.819  INFO 3020 --- [           main] o.s.c.n.eureka.InstanceInfoFactory       : Setting initial instance status as: STARTING
2019-03-11 16:06:56.865  INFO 3020 --- [           main] com.netflix.discovery.DiscoveryClient    : Initializing Eureka in region us-east-1
2019-03-11 16:06:57.097  INFO 3020 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2019-03-11 16:06:57.097  INFO 3020 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2019-03-11 16:06:57.218  INFO 3020 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2019-03-11 16:06:57.218  INFO 3020 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2019-03-11 16:06:57.399  INFO 3020 --- [           main] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2019-03-11 16:06:57.463  INFO 3020 --- [           main] com.netflix.discovery.DiscoveryClient    : Disable delta property : false
2019-03-11 16:06:57.463  INFO 3020 --- [           main] com.netflix.discovery.DiscoveryClient    : Single vip registry refresh property : null
2019-03-11 16:06:57.463  INFO 3020 --- [           main] com.netflix.discovery.DiscoveryClient    : Force full registry fetch : false
2019-03-11 16:06:57.463  INFO 3020 --- [           main] com.netflix.discovery.DiscoveryClient    : Application is null : false
2019-03-11 16:06:57.463  INFO 3020 --- [           main] com.netflix.discovery.DiscoveryClient    : Registered Applications size is zero : true
2019-03-11 16:06:57.463  INFO 3020 --- [           main] com.netflix.discovery.DiscoveryClient    : Application version is -1: true
2019-03-11 16:06:57.463  INFO 3020 --- [           main] com.netflix.discovery.DiscoveryClient    : Getting all instance registry info from the eureka server
2019-03-11 16:06:57.590  INFO 3020 --- [           main] com.netflix.discovery.DiscoveryClient    : The response status is 200
2019-03-11 16:06:57.593  INFO 3020 --- [           main] com.netflix.discovery.DiscoveryClient    : Starting heartbeat executor: renew interval is: 30
2019-03-11 16:06:57.595  INFO 3020 --- [           main] c.n.discovery.InstanceInfoReplicator     : InstanceInfoReplicator onDemand update allowed rate per min is 4
2019-03-11 16:06:57.599  INFO 3020 --- [           main] com.netflix.discovery.DiscoveryClient    : Discovery Client initialized at timestamp 1552291617598 with initial instances count: 1
2019-03-11 16:06:57.603  INFO 3020 --- [           main] o.s.c.n.e.s.EurekaServiceRegistry        : Registering application CONSUME-CLIENT with eureka with status UP
2019-03-11 16:06:57.603  INFO 3020 --- [           main] com.netflix.discovery.DiscoveryClient    : Saw local status change event StatusChangeEvent [timestamp=1552291617603, current=UP, previous=STARTING]
2019-03-11 16:06:57.605  INFO 3020 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_CONSUME-CLIENT/localhost:consume-client:8763: registering service...
2019-03-11 16:06:57.643  INFO 3020 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_CONSUME-CLIENT/localhost:consume-client:8763 - registration status: 204
2019-03-11 16:06:57.645  INFO 3020 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8763 (http) with context path ''
2019-03-11 16:06:57.646  INFO 3020 --- [           main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8763
2019-03-11 16:06:57.649  INFO 3020 --- [           main] c.w.s.comsumeclient.ConsumeApplication   : Started ConsumeApplication in 10.171 seconds (JVM running for 10.568)
2019-03-11 16:06:57.651  INFO 3020 --- [           main] c.w.s.comsumeclient.ConsumeApplication   : application init success

刷新http://localhost:8761/

spring-cloud-eureka服务发现注册中心及spring-cloud微服务_第3张图片

浏览器输入http://localhost:8763/consume

结果如下

 一般情况下我们的微服务都是多机部署的,下面用不同的端口来模拟这种情况

先将我们的client打包

D:\workspace\wl\study\spring-cloud>cd client

D:\workspace\wl\study\spring-cloud\client>mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.wl.springcloud:client >----------------------
[INFO] Building client 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ client ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ client ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to D:\workspace\wl\study\spring-cloud\client\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ client ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\workspace\wl\study\spring-cloud\client\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ client ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to D:\workspace\wl\study\spring-cloud\client\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ client ---
[INFO] Surefire report directory: D:\workspace\wl\study\spring-cloud\client\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.wl.springcloud.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.043 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ client ---
[INFO] Building jar: D:\workspace\wl\study\spring-cloud\client\target\client-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.0.3.RELEASE:repackage (default) @ client ---
[INFO] Layout: JAR
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.829 s
[INFO] Finished at: 2019-03-11T16:10:18+08:00
[INFO] ------------------------------------------------------------------------

进入target  指定server.port=8765另起一个client服务

D:\workspace\wl\study\spring-cloud\client>cd target

D:\workspace\wl\study\spring-cloud\client\target>java -jar client-1.0-SNAPSHOT.jar --server.port=8765
2019-03-11 16:12:01.851  INFO 12888 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@34033bd0: startup date [Mon Mar 11 16:12:01 CST 2019]; root of context hierarchy
2019-03-11 16:12:02.051  INFO 12888 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-03-11 16:12:02.078  INFO 12888 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$a80679d9] is not eligible
 for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

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

2019-03-11 16:12:03.304  INFO 12888 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2019-03-11 16:12:04.398  INFO 12888 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8888. Will be trying the next url if available
2019-03-11 16:12:04.399  WARN 12888 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/provider-client/default": Connection refused: connect; nested exception is java.net.ConnectException: Connection refus
ed: connect
2019-03-11 16:12:04.404  INFO 12888 --- [           main] c.w.s.client.ProviderApplication         : No active profile set, falling back to default profiles: default
2019-03-11 16:12:04.415  INFO 12888 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@7085bdee: startup date [Mon Mar 11 16:12:04 CST 2019]; parent: org.springframework.context.annot
ation.AnnotationConfigApplicationContext@34033bd0
2019-03-11 16:12:04.846  INFO 12888 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=aed0e163-d024-3b1c-b7d4-182b8430f378
2019-03-11 16:12:04.860  INFO 12888 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-03-11 16:12:04.941  INFO 12888 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$Enhancer
BySpringCGLIB$$a80679d9] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-11 16:12:05.232  INFO 12888 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8765 (http)
2019-03-11 16:12:05.251  INFO 12888 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-03-11 16:12:05.251  INFO 12888 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.31
2019-03-11 16:12:05.259  INFO 12888 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : Loaded APR based Apache Tomcat Native library [1.2.17] using APR version [1.6.3].
2019-03-11 16:12:05.260  INFO 12888 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2019-03-11 16:12:05.260  INFO 12888 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
2019-03-11 16:12:06.280  INFO 12888 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : OpenSSL successfully initialized [OpenSSL 1.0.2o  27 Mar 2018]
2019-03-11 16:12:06.403  INFO 12888 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-03-11 16:12:06.403  INFO 12888 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1988 ms
2019-03-11 16:12:06.510  INFO 12888 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2019-03-11 16:12:06.513  INFO 12888 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2019-03-11 16:12:06.514  INFO 12888 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-03-11 16:12:06.514  INFO 12888 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2019-03-11 16:12:06.514  INFO 12888 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2019-03-11 16:12:06.579  WARN 12888 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2019-03-11 16:12:06.580  INFO 12888 --- [           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.
2019-03-11 16:12:06.585  WARN 12888 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2019-03-11 16:12:06.585  INFO 12888 --- [           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.
2019-03-11 16:12:06.661  INFO 12888 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-11 16:12:06.828  INFO 12888 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@7085bdee: startup date [Mon Mar 11 16:12:04 CST 2019]; parent: org.springfra
mework.context.annotation.AnnotationConfigApplicationContext@34033bd0
2019-03-11 16:12:06.881  INFO 12888 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/provider]}" onto public java.lang.String com.wl.springcloud.client.ProviderController.provider()
2019-03-11 16:12:06.884  INFO 12888 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.er
ror(javax.servlet.http.HttpServletRequest)
2019-03-11 16:12:06.885  INFO 12888 --- [           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.servlet.error.BasicErrorController.errorHtml(javax.servlet.htt
p.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2019-03-11 16:12:06.905  INFO 12888 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-11 16:12:06.905  INFO 12888 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-11 16:12:08.184  INFO 12888 --- [           main] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
2019-03-11 16:12:09.283  INFO 12888 --- [           main] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
2019-03-11 16:12:09.412  INFO 12888 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2019-03-11 16:12:09.418  INFO 12888 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'configurationPropertiesRebinder' has been autodetected for JMX exposure
2019-03-11 16:12:09.419  INFO 12888 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'environmentManager' has been autodetected for JMX exposure
2019-03-11 16:12:09.419  INFO 12888 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'refreshScope' has been autodetected for JMX exposure
2019-03-11 16:12:09.421  INFO 12888 --- [           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]
2019-03-11 16:12:09.429  INFO 12888 --- [           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]
2019-03-11 16:12:09.437  INFO 12888 --- [           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=7085bdee,type=Confi
gurationPropertiesRebinder]
2019-03-11 16:12:09.445  INFO 12888 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
2019-03-11 16:12:09.457  INFO 12888 --- [           main] o.s.c.n.eureka.InstanceInfoFactory       : Setting initial instance status as: STARTING
2019-03-11 16:12:09.494  INFO 12888 --- [           main] com.netflix.discovery.DiscoveryClient    : Initializing Eureka in region us-east-1
2019-03-11 16:12:09.707  INFO 12888 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2019-03-11 16:12:09.708  INFO 12888 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2019-03-11 16:12:09.828  INFO 12888 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2019-03-11 16:12:09.828  INFO 12888 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2019-03-11 16:12:09.968  INFO 12888 --- [           main] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2019-03-11 16:12:10.032  INFO 12888 --- [           main] com.netflix.discovery.DiscoveryClient    : Disable delta property : false
2019-03-11 16:12:10.032  INFO 12888 --- [           main] com.netflix.discovery.DiscoveryClient    : Single vip registry refresh property : null
2019-03-11 16:12:10.032  INFO 12888 --- [           main] com.netflix.discovery.DiscoveryClient    : Force full registry fetch : false
2019-03-11 16:12:10.032  INFO 12888 --- [           main] com.netflix.discovery.DiscoveryClient    : Application is null : false
2019-03-11 16:12:10.032  INFO 12888 --- [           main] com.netflix.discovery.DiscoveryClient    : Registered Applications size is zero : true
2019-03-11 16:12:10.033  INFO 12888 --- [           main] com.netflix.discovery.DiscoveryClient    : Application version is -1: true
2019-03-11 16:12:10.033  INFO 12888 --- [           main] com.netflix.discovery.DiscoveryClient    : Getting all instance registry info from the eureka server
2019-03-11 16:12:10.159  INFO 12888 --- [           main] com.netflix.discovery.DiscoveryClient    : The response status is 200
2019-03-11 16:12:10.162  INFO 12888 --- [           main] com.netflix.discovery.DiscoveryClient    : Starting heartbeat executor: renew interval is: 30
2019-03-11 16:12:10.164  INFO 12888 --- [           main] c.n.discovery.InstanceInfoReplicator     : InstanceInfoReplicator onDemand update allowed rate per min is 4
2019-03-11 16:12:10.167  INFO 12888 --- [           main] com.netflix.discovery.DiscoveryClient    : Discovery Client initialized at timestamp 1552291930166 with initial instances count: 2
2019-03-11 16:12:10.170  INFO 12888 --- [           main] o.s.c.n.e.s.EurekaServiceRegistry        : Registering application PROVIDER-CLIENT with eureka with status UP
2019-03-11 16:12:10.171  INFO 12888 --- [           main] com.netflix.discovery.DiscoveryClient    : Saw local status change event StatusChangeEvent [timestamp=1552291930171, current=UP, previous=STARTING]
2019-03-11 16:12:10.172  INFO 12888 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_PROVIDER-CLIENT/localhost:provider-client:8765: registering service...
2019-03-11 16:12:10.230  INFO 12888 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_PROVIDER-CLIENT/localhost:provider-client:8765 - registration status: 204
2019-03-11 16:12:10.233  INFO 12888 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8765 (http) with context path ''
2019-03-11 16:12:10.234  INFO 12888 --- [           main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8765
2019-03-11 16:12:10.237  INFO 12888 --- [           main] c.w.s.client.ProviderApplication         : Started ProviderApplication in 9.805 seconds (JVM running for 10.17)
2019-03-11 16:12:10.240  INFO 12888 --- [           main] c.w.s.client.ProviderApplication         : application init success

刷新两次http://localhost:8763/consume(可能要等一会才能看到效果)

spring-cloud-eureka服务发现注册中心及spring-cloud微服务_第4张图片 

刷新http://localhost:8761/

spring-cloud-eureka服务发现注册中心及spring-cloud微服务_第5张图片 

 

上面就是一个简单的spring-cloud微服务的例子

eureka常见问题参考 http://www.itmuch.com/spring-cloud-sum-eureka/

eureka配置参考 https://www.cnblogs.com/chry/p/7992885.html

spring-cloud与dubbo的比较参考 https://www.cnblogs.com/aspirant/p/9089146.html

spring-cloud例子参考https://github.com/spring-cloud-samples

你可能感兴趣的:(spring-cloud)