Spring基础:快速入门spring cloud(2):服务发现之eureka

news/2024/11/17 9:26:23/

这里写图片描述

Spring Cloud是Spring总多的Project中的一个,它提供了一整套的工具帮助系统架构师们在进行分布式设计的时候可以拿来即用, 在创建和发布微服务时极为便捷和有效。本系列文章将会使用最简单的例子和最为容易的方式来学习Spring Cloud。本文将会介绍如何使用Spring Cloud的Eureka实现服务发现。

构成

Spring Cloud由很多子项目构成,为了介绍方便,挑出一些项目中常用的进行如下构成。

这里写图片描述

具体各个Service之间的关系不再一一展示,将其粗暴地分为框架类服务(Spring Cloud服务)也业务逻辑服务两种,各服务功能和实现简单如下说明。

项目详细
Config ServiceSpring Cloud Config:统一配置管理服务
Dashboard ServiceHystrix Dashboard
Api Route ServiceZuul:Api Gateway
Discovery ServiceEureka:服务发现
User ServiceRESTFUL的用户相关的服务
Org ServiceRESTFUL的组织相关的服务

Discovery Service

这里写图片描述

本文将会用最简单的方式来介绍如何使用Eureka进行服务发现的,以及Spring Cloud中使用Eureka是如何方便。

Sprint Boot项目

创建一个Spring Boot项目,详细不再介绍, 集体方法可以参看如下文档。

项目详细
SPRING INITIALIZRhttp://blog.csdn.net/liumiaocn/article/details/53442364

Eureka Server

Pom设定

需要将 <artifactId>spring-cloud-starter-eureka-server</artifactId>加入到POM中,可以参照如下Pom示例。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.liumiaocn.demo.springcloud</groupId><artifactId>discoveryservice</artifactId><version>0.0.1-SNAPSHOT</version><packaging>jar</packaging><name>discoveryservice</name><description>Demo project for Spring Boot</description><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>1.4.3.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><java.version>1.8</java.version></properties><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-eureka-server</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies><dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>Camden.BUILD-SNAPSHOT</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build><repositories><repository><id>spring-snapshots</id><name>Spring Snapshots</name><url>https://repo.spring.io/snapshot</url><snapshots><enabled>true</enabled></snapshots></repository><repository><id>spring-milestones</id><name>Spring Milestones</name><url>https://repo.spring.io/milestone</url><snapshots><enabled>false</enabled></snapshots></repository></repositories></project>

注解

加入注解EnableEurekaServer,在Spring boot的应用中只需这样一行就将EurekaServer引入其中。

package com.liumiaocn.demo.springcloud;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;@SpringBootApplication
@EnableEurekaServer
public class DiscoveryserviceApplication {public static void main(String[] args) {SpringApplication.run(DiscoveryserviceApplication.class, args);}
}

设定文件

使用bootstrap和application两个设定文件来进行相关设定,入门时为了更加快速,使用最少的设定文件和设定语句,基本上只有不可或缺的才会加上,入门之后详细内容参看spring cloud官方文档即可。application.properties文件的最少作如下设定即可。

server.port=8801
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.client.serviceUrl.defaultZone=http://localhost:${server.port}/eureka/
项目详细
server.portEureka Server的Dashboard所使用的port
eureka.client.register-with-eureka是否要注册到服务器端,因为此处为Eureka Server,所以设定为false
eureka.client.fetch-registry是否从服务器端取得注册信息,因为此处为Eureka Server,所以设定为false
eureka.client.serviceUrl.defaultZone设定为为http://localhost:8801/eureka/,缺省为8761端口。

启动

2016-12-28 07:59:33.200  INFO 5228 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@c86b9e3: startup date [Wed Dec 28 07:59:33 CST 2016]; root of context hierarchy
2016-12-28 07:59:33.434  INFO 5228 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2016-12-28 07:59:33.466  INFO 5228 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$fb56a29e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying).   ____          _            __ _ _/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/  ___)| |_)| | | | | || (_| |  ) ) ) )'  |____| .__|_| |_|_| |_\__, | / / / /=========|_|==============|___/=/_/_/_/:: Spring Boot ::        (v1.4.3.RELEASE)2016-12-28 07:59:33.902  INFO 5228 --- [           main] c.l.d.s.DiscoveryserviceApplication      : No active profile set, falling back to default profiles: default
2016-12-28 07:59:33.902  INFO 5228 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@35229f85: startup date [Wed Dec 28 07:59:33 CST 2016]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@c86b9e3
2016-12-28 07:59:34.796  WARN 5228 --- [           main] o.s.c.a.ConfigurationClassPostProcessor  : Cannot enhance @Configuration bean definition 'refreshScope' since its singleton instance has been created too early. The typical cause is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.
2016-12-28 07:59:34.967  INFO 5228 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=37576f2c-11e3-3d56-80ff-2435c6a59fa3
2016-12-28 07:59:35.030  INFO 5228 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2016-12-28 07:59:35.139  INFO 5228 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$fb56a29e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-12-28 07:59:35.562  INFO 5228 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8801 (http)
2016-12-28 07:59:35.578  INFO 5228 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2016-12-28 07:59:35.578  INFO 5228 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.6
2016-12-28 07:59:35.687  INFO 5228 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2016-12-28 07:59:35.687  INFO 5228 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1785 ms
2016-12-28 07:59:36.248  INFO 5228 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'metricsFilter' to: [/*]
2016-12-28 07:59:36.248  INFO 5228 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-12-28 07:59:36.248  INFO 5228 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-12-28 07:59:36.248  INFO 5228 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-12-28 07:59:36.248  INFO 5228 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2016-12-28 07:59:36.248  INFO 5228 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'webRequestTraceFilter' to: [/*]
2016-12-28 07:59:36.248  INFO 5228 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'servletContainer' to urls: [/eureka/*]
2016-12-28 07:59:36.248  INFO 5228 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'applicationContextIdFilter' to: [/*]
2016-12-28 07:59:36.248  INFO 5228 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2016-12-28 07:59:36.342  INFO 5228 --- [ost-startStop-1] c.s.j.s.i.a.WebApplicationImpl           : Initiating Jersey application, version 'Jersey: 1.19.1 03/11/2016 02:08 PM'
2016-12-28 07:59:36.404  INFO 5228 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2016-12-28 07:59:36.404  INFO 5228 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2016-12-28 07:59:36.514  INFO 5228 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2016-12-28 07:59:36.514  INFO 5228 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2016-12-28 07:59:37.230  INFO 5228 --- [           main] o.s.c.n.eureka.InstanceInfoFactory       : Setting initial instance status as: STARTING
2016-12-28 07:59:37.292  INFO 5228 --- [           main] com.netflix.discovery.DiscoveryClient    : Client configured to neither register nor query for data.
2016-12-28 07:59:37.292  INFO 5228 --- [           main] com.netflix.discovery.DiscoveryClient    : Discovery Client initialized at timestamp 1482883177292 with initial instances count: 0
2016-12-28 07:59:37.370  INFO 5228 --- [           main] c.n.eureka.DefaultEurekaServerContext    : Initializing ...
2016-12-28 07:59:37.370  INFO 5228 --- [           main] c.n.eureka.cluster.PeerEurekaNodes       : Adding new peer nodes [http://localhost:8761/eureka/]
2016-12-28 07:59:37.682  INFO 5228 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2016-12-28 07:59:37.682  INFO 5228 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2016-12-28 07:59:37.682  INFO 5228 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2016-12-28 07:59:37.682  INFO 5228 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2016-12-28 07:59:37.791  INFO 5228 --- [           main] c.n.eureka.cluster.PeerEurekaNodes       : Replica node URL:  http://localhost:8761/eureka/
2016-12-28 07:59:37.807  INFO 5228 --- [           main] c.n.e.registry.AbstractInstanceRegistry  : Finished initializing remote region registries. All known remote regions: []
2016-12-28 07:59:37.807  INFO 5228 --- [           main] c.n.eureka.DefaultEurekaServerContext    : Initialized
2016-12-28 07:59:38.103  INFO 5228 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@35229f85: startup date [Wed Dec 28 07:59:33 CST 2016]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@c86b9e3
2016-12-28 07:59:38.228  INFO 5228 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/],methods=[GET]}" onto public java.lang.String org.springframework.cloud.netflix.eureka.server.EurekaController.status(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.Object>)
2016-12-28 07:59:38.228  INFO 5228 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/lastn],methods=[GET]}" onto public java.lang.String org.springframework.cloud.netflix.eureka.server.EurekaController.lastn(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.Object>)
2016-12-28 07:59:38.228  INFO 5228 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2016-12-28 07:59:38.228  INFO 5228 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2016-12-28 07:59:38.259  INFO 5228 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-12-28 07:59:38.259  INFO 5228 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-12-28 07:59:38.290  INFO 5228 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-12-28 07:59:38.836  INFO 5228 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/mappings || /mappings.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-12-28 07:59:38.836  INFO 5228 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/health || /health.json],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke(java.security.Principal)
2016-12-28 07:59:38.836  INFO 5228 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/beans || /beans.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-12-28 07:59:38.836  INFO 5228 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/info || /info.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-12-28 07:59:38.836  INFO 5228 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/restart || /restart.json],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.context.restart.RestartMvcEndpoint.invoke()
2016-12-28 07:59:38.836  INFO 5228 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/refresh || /refresh.json],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.endpoint.GenericPostableMvcEndpoint.invoke()
2016-12-28 07:59:38.836  INFO 5228 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/dump || /dump.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-12-28 07:59:38.836  INFO 5228 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/configprops || /configprops.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-12-28 07:59:38.836  INFO 5228 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/resume || /resume.json],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.endpoint.GenericPostableMvcEndpoint.invoke()
2016-12-28 07:59:38.852  INFO 5228 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/trace || /trace.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-12-28 07:59:38.852  INFO 5228 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/env],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.context.environment.EnvironmentManagerMvcEndpoint.value(java.util.Map<java.lang.String, java.lang.String>)
2016-12-28 07:59:38.852  INFO 5228 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/env/reset],methods=[POST]}" onto public java.util.Map<java.lang.String, java.lang.Object> org.springframework.cloud.context.environment.EnvironmentManagerMvcEndpoint.reset()
2016-12-28 07:59:38.852  INFO 5228 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/metrics/{name:.*}],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint.value(java.lang.String)
2016-12-28 07:59:38.852  INFO 5228 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/metrics || /metrics.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-12-28 07:59:38.852  INFO 5228 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/heapdump || /heapdump.json],methods=[GET],produces=[application/octet-stream]}" onto public void org.springframework.boot.actuate.endpoint.mvc.HeapdumpMvcEndpoint.invoke(boolean,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.io.IOException,javax.servlet.ServletException
2016-12-28 07:59:38.852  INFO 5228 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/pause || /pause.json],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.endpoint.GenericPostableMvcEndpoint.invoke()
2016-12-28 07:59:38.852  INFO 5228 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/autoconfig || /autoconfig.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-12-28 07:59:38.852  INFO 5228 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/archaius || /archaius.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-12-28 07:59:38.852  INFO 5228 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/env/{name:.*}],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint.value(java.lang.String)
2016-12-28 07:59:38.852  INFO 5228 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/env || /env.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-12-28 07:59:38.868  INFO 5228 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/features || /features.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-12-28 07:59:38.977  INFO 5228 --- [           main] o.s.ui.freemarker.SpringTemplateLoader   : SpringTemplateLoader for FreeMarker: using resource loader [org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@35229f85: startup date [Wed Dec 28 07:59:33 CST 2016]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@c86b9e3] and template loader path [classpath:/templates/]
2016-12-28 07:59:38.977  INFO 5228 --- [           main] o.s.w.s.v.f.FreeMarkerConfigurer         : ClassTemplateLoader for Spring macros added to FreeMarker configuration
2016-12-28 07:59:39.070  WARN 5228 --- [           main] o.s.c.n.a.ArchaiusAutoConfiguration      : No spring.application.name found, defaulting to 'application'
2016-12-28 07:59:39.070  WARN 5228 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2016-12-28 07:59:39.070  INFO 5228 --- [           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.
2016-12-28 07:59:39.086  WARN 5228 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2016-12-28 07:59:39.086  INFO 5228 --- [           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.
2016-12-28 07:59:39.164  INFO 5228 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2016-12-28 07:59:39.164  INFO 5228 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'refreshScope' has been autodetected for JMX exposure
2016-12-28 07:59:39.164  INFO 5228 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'environmentManager' has been autodetected for JMX exposure
2016-12-28 07:59:39.164  INFO 5228 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'configurationPropertiesRebinder' has been autodetected for JMX exposure
2016-12-28 07:59:39.164  INFO 5228 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'refreshEndpoint' has been autodetected for JMX exposure
2016-12-28 07:59:39.164  INFO 5228 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'restartEndpoint' has been autodetected for JMX exposure
2016-12-28 07:59:39.164  INFO 5228 --- [           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]
2016-12-28 07:59:39.180  INFO 5228 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'restartEndpoint': registering with JMX server as MBean [org.springframework.cloud.context.restart:name=restartEndpoint,type=RestartEndpoint]
2016-12-28 07:59:39.195  INFO 5228 --- [           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]
2016-12-28 07:59:39.195  INFO 5228 --- [           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=35229f85,type=ConfigurationPropertiesRebinder]
2016-12-28 07:59:39.212  INFO 5228 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'refreshEndpoint': registering with JMX server as MBean [org.springframework.cloud.endpoint:name=refreshEndpoint,type=RefreshEndpoint]
2016-12-28 07:59:39.369  INFO 5228 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
2016-12-28 07:59:39.384  INFO 5228 --- [      Thread-10] o.s.c.n.e.server.EurekaServerBootstrap   : Setting the eureka configuration..
2016-12-28 07:59:39.384  INFO 5228 --- [           main] c.n.e.EurekaDiscoveryClientConfiguration : Registering application unknown with eureka with status UP
2016-12-28 07:59:39.384  INFO 5228 --- [      Thread-10] o.s.c.n.e.server.EurekaServerBootstrap   : Eureka data center value eureka.datacenter is not set, defaulting to default
2016-12-28 07:59:39.384  INFO 5228 --- [      Thread-10] o.s.c.n.e.server.EurekaServerBootstrap   : Eureka environment value eureka.environment is not set, defaulting to test
2016-12-28 07:59:39.384  INFO 5228 --- [      Thread-10] o.s.c.n.e.server.EurekaServerBootstrap   : isAws returned false
2016-12-28 07:59:39.384  INFO 5228 --- [      Thread-10] o.s.c.n.e.server.EurekaServerBootstrap   : Initialized server context
2016-12-28 07:59:39.384  INFO 5228 --- [      Thread-10] c.n.e.r.PeerAwareInstanceRegistryImpl    : Got 1 instances from neighboring DS node
2016-12-28 07:59:39.384  INFO 5228 --- [      Thread-10] c.n.e.r.PeerAwareInstanceRegistryImpl    : Renew threshold is: 1
2016-12-28 07:59:39.384  INFO 5228 --- [      Thread-10] c.n.e.r.PeerAwareInstanceRegistryImpl    : Changing status to UP
2016-12-28 07:59:39.400  INFO 5228 --- [      Thread-10] e.s.EurekaServerInitializerConfiguration : Started Eureka Server
2016-12-28 07:59:39.462  INFO 5228 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8801 (http)
2016-12-28 07:59:39.462  INFO 5228 --- [           main] c.n.e.EurekaDiscoveryClientConfiguration : Updating port to 8801
2016-12-28 07:59:39.478  INFO 5228 --- [           main] c.l.d.s.DiscoveryserviceApplication      : Started DiscoveryserviceApplication in 7.073 seconds (JVM running for 7.555)

Eureka Server

使用8081port就可以访问到Eureka Server的Dashboard了,从这里可以清楚地看到[Instances currently registered with Eureka]下还没有任何服务注册到这里。

home

这里写图片描述

lastn

这里写图片描述

总结

这篇文章中我们了解到了如何简单的通过1行注解和3行设定即可启动服务发现功能的Eureka的Server端,在接下来的文章中,你将会看到Client端如何注册到Eureka的Server以及其他各种组件的使用方法。


http://www.ppmy.cn/news/182247.html

相关文章

WS2812 RGB灯

文章目录 一、简介二、原理三、硬件介绍四、通信协议五、程序 一、简介 WS2812只需要一根信号线就能控制灯的多种颜色的变化&#xff0c;多个灯可以级联&#xff0c;在30hz的刷新频率下一个信号线能够控制至多500个LED。 二、原理 WS2812B是一个集控制电路与发光电路于一体的…

Spring Data JPA想要学得好,缓存机制掌握好

文章目录 Spring Data JPA想要学得好&#xff0c;缓存机制掌握好Hibernate、JPA与Spring Data JPA之间的关系JPA的EntityManager接口与Hibernate的Session接口Hibernate的缓存Hibernate的一级缓存&#xff08;Session的缓存&#xff09;浅读缓存源码解密缓存过程Hibernate的一级…

python中random函数的使用方法 详解

# random各种使用方法 import random# 随机生成[0.1)的浮点数 print("random():", random.random())# 随机生成1000-9999之间的整数 print("randint(1000, 9999):", random.randint(1000, 9999))# 随机生成0-20之间的偶数 print("randrange(0, 21, 2)…

树莓派实现简单网站服务器

树莓派实现服务器&#xff08;外网访问&#xff09; 获取域名&#xff08;内网穿透&#xff09;好文请先阅读获取域名运行代理的客户端程序本地搭建一个网页树莓派实现代理服务器&#xff08;V*N&#xff09;配置为启动脚本 获取域名&#xff08;内网穿透&#xff09; 好文请…

linux下查询当前所有连接的ip

Linux 系统有很多用于快速处理数据的工具如 grep , awk , cut , sort , uniq , sort 可以帮助我们分析网络情况 , 他们非常非常地好用 , 如果你熟练掌握他们的使用技巧 , 他们则可以帮你快速定位问题 ; 接下来一步步来查看访问系统的 IP 情况 通过 netstat -ntu , 找出通过 tc…

解决openstack “failed to connect to server (code: 1006)”故障一例

openstack版本环境&#xff1a;ocata 安装完成ocata版本后&#xff0c;新建主机实例后&#xff0c;通过管理端进入主机实例的控制台时&#xff0c;报错&#xff1a;“failed to connect to server (code: 1006)” 解决思路&#xff1a; 1、检查日志文件&#xff0c;通过日志寻…

CVE-2016-2183

CVE-2016-2183-SSL/TLS协议信息泄露漏洞 漏洞描述 TLS, SSH, IPSec 协商及其他产品中使用的DES及Triple DES密码存在大约四十亿块的生日界&#xff0c;这可使远程攻击者通过Sweet32攻击&#xff0c;获取纯文本数据。 该漏洞又称为 SWEET32&#xff0c;是对较旧的分组密码算法…

Packet Tracer - 交换机端口安全故障排除

Packet Tracer - 交换机端口安全故障排除 场景 通常使用 PC1 的员工将家里的笔记本电脑带来&#xff0c;然后断开 PC1 的连接并将笔记本电脑连接到电信插座。 在提醒此安全策略不支持在网络上使用个人设备后&#xff0c;您必须重新连接 PC1 并重新启用端口。 拓扑图 要求 …