//Eureka server
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
}
}
//Discovered service
@SpringBootApplication
@EnableDiscoveryClient
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
# properties for discovered service
spring.application.name=<app-name>
spring.profiles.active=default
spring.cloud.config.uri=http://localhost:8888
server.port=9100
eureka.client.service-url.default-zone=http://localhost:8761/eureka
# properties for eureka
spring.application.name=symphony-nlp-eureka-server
server.port=8761
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
// Service LOGS
2018-01-30 09:25:17.222 INFO [restartedMain] [ConfigServicePropertySourceLocator] Fetching config from server at: http://localhost:8888
2018-01-30 09:25:17.387 INFO [restartedMain] [ConfigServicePropertySourceLocator] Located environment: name=<app-name>, profiles=[default], label=null, version=null, state=null
2018-01-30 09:25:17.387 INFO [restartedMain] [PropertySourceBootstrapConfiguration] Located property source: CompositePropertySource {name='configService', propertySources=[MapPropertySource {name='classpath:/<app-name>.yml'}]}
2018-01-30 09:25:17.394 INFO [restartedMain] [<app-name>] The following profiles are active: default
2018-01-30 09:25:17.405 INFO [restartedMain] [AnnotationConfigServletWebServerApplicationContext] Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@14f7cee: startup date [Tue Jan 30 09:25:17 GMT 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@121507b
2018-01-30 09:25:18.802 INFO [restartedMain] [DefaultListableBeanFactory] Overriding bean definition for bean 'environmentWebEndpointExtension' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.actuate.autoconfigure.env.EnvironmentEndpointAutoConfiguration; factoryMethodName=environmentWebEndpointExtension; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/actuate/autoconfigure/env/EnvironmentEndpointAutoConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.autoconfigure.LifecycleMvcEndpointAutoConfiguration; factoryMethodName=environmentWebEndpointExtension; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cloud/autoconfigure/LifecycleMvcEndpointAutoConfiguration.class]]
2018-01-30 09:25:19.020 INFO [restartedMain] [GenericScope] BeanFactory id=270e5605-a6fb-3ddf-90f9-1ab7f8277113
2018-01-30 09:25:19.031 INFO [restartedMain] [AutowiredAnnotationBeanPostProcessor] JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-01-30 09:25:19.062 INFO [restartedMain] [PostProcessorRegistrationDelegate$BeanPostProcessorChecker] Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$69f84f5b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-01-30 09:25:19.118 INFO [restartedMain] [ValidatorFactoryImpl] HV000238: Temporal validation tolerance set to 0.
2018-01-30 09:25:19.437 INFO [restartedMain] [TomcatWebServer] Tomcat initialized with port(s): 9100 (http)
2018-01-30 09:25:19.447 INFO [restartedMain] [StandardService] Starting service [Tomcat]
2018-01-30 09:25:19.447 INFO [restartedMain] [StandardEngine] Starting Servlet Engine: Apache Tomcat/8.5.23
2018-01-30 09:25:19.454 INFO [localhost-startStop-1] [AprLifecycleListener] The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: <listing the java path>
2018-01-30 09:25:19.575 INFO [localhost-startStop-1] [[/]] Initializing Spring embedded WebApplicationContext
2018-01-30 09:25:19.576 INFO [localhost-startStop-1] [ContextLoader] Root WebApplicationContext: initialization completed in 2171 ms
2018-01-30 09:25:19.903 INFO [localhost-startStop-1] [RequestMappingHandlerMapping] Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-01-30 09:25:19.903 INFO [localhost-startStop-1] [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)
2018-01-30 09:25:19.969 INFO [localhost-startStop-1] [SimpleUrlHandlerMapping] Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-30 09:25:19.969 INFO [localhost-startStop-1] [SimpleUrlHandlerMapping] Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-30 09:25:19.998 INFO [localhost-startStop-1] [SimpleUrlHandlerMapping] Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-30 09:25:20.742 INFO [localhost-startStop-1] [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.WebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2018-01-30 09:25:20.743 INFO [localhost-startStop-1] [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.WebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2018-01-30 09:25:20.743 INFO [localhost-startStop-1] [WebMvcEndpointHandlerMapping] Mapped "{[/actuator],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto private java.util.Map<java.lang.String, java.util.Map<java.lang.String, org.springframework.boot.actuate.endpoint.web.Link>> org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping.links(javax.servlet.http.HttpServletRequest)
2018-01-30 09:25:20.805 INFO [localhost-startStop-1] [ServletRegistrationBean] Mapping servlet: 'dispatcherServlet' to [/]
2018-01-30 09:25:20.809 INFO [localhost-startStop-1] [FilterRegistrationBean] Mapping filter: 'webMetricsFilter' to: [/*]
2018-01-30 09:25:20.809 INFO [localhost-startStop-1] [FilterRegistrationBean] Mapping filter: 'characterEncodingFilter' to: [/*]
2018-01-30 09:25:20.809 INFO [localhost-startStop-1] [FilterRegistrationBean] Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-01-30 09:25:20.810 INFO [localhost-startStop-1] [FilterRegistrationBean] Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-01-30 09:25:20.810 INFO [localhost-startStop-1] [FilterRegistrationBean] Mapping filter: 'requestContextFilter' to: [/*]
2018-01-30 09:25:20.810 INFO [localhost-startStop-1] [FilterRegistrationBean] Mapping filter: 'webRequestLoggingFilter' to: [/*]
2018-01-30 09:25:20.838 INFO [restartedMain] [MessageBroker] creating message broker
2018-01-30 09:25:22.197 INFO [restartedMain] [Authentication] Successfully retrieved tokens
2018-01-30 09:25:22.399 WARN [restartedMain] [URLConfigurationSource] No URLs will be polled as dynamic configuration sources.
2018-01-30 09:25:22.399 INFO [restartedMain] [URLConfigurationSource] To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2018-01-30 09:25:22.404 WARN [restartedMain] [URLConfigurationSource] No URLs will be polled as dynamic configuration sources.
2018-01-30 09:25:22.404 INFO [restartedMain] [URLConfigurationSource] To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2018-01-30 09:25:22.445 INFO [restartedMain] [ValidatorFactoryImpl] HV000238: Temporal validation tolerance set to 0.
2018-01-30 09:25:22.518 INFO [restartedMain] [RequestMappingHandlerAdapter] Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@14f7cee: startup date [Tue Jan 30 09:25:17 GMT 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@121507b
2018-01-30 09:25:22.818 WARN [restartedMain] [OptionalLiveReloadServer] Unable to start LiveReload server
2018-01-30 09:25:23.020 INFO [restartedMain] [AnnotationMBeanExporter] Registering beans for JMX exposure on startup
2018-01-30 09:25:23.028 INFO [restartedMain] [AnnotationMBeanExporter] Bean with name 'configurationPropertiesRebinder' has been autodetected for JMX exposure
2018-01-30 09:25:23.029 INFO [restartedMain] [AnnotationMBeanExporter] Bean with name 'environmentManager' has been autodetected for JMX exposure
2018-01-30 09:25:23.030 INFO [restartedMain] [AnnotationMBeanExporter] Bean with name 'refreshScope' has been autodetected for JMX exposure
2018-01-30 09:25:23.031 INFO [restartedMain] [AnnotationMBeanExporter] Located managed bean 'environmentManager': registering with JMX server as MBean [org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager]
2018-01-30 09:25:23.038 INFO [restartedMain] [AnnotationMBeanExporter] Located managed bean 'refreshScope': registering with JMX server as MBean [org.springframework.cloud.context.scope.refresh:name=refreshScope,type=RefreshScope]
2018-01-30 09:25:23.048 INFO [restartedMain] [AnnotationMBeanExporter] Located managed bean 'configurationPropertiesRebinder': registering with JMX server as MBean [org.springframework.cloud.context.properties:name=configurationPropertiesRebinder,context=14f7cee,type=ConfigurationPropertiesRebinder]
2018-01-30 09:25:23.088 INFO [restartedMain] [DefaultLifecycleProcessor] Starting beans in phase 0
2018-01-30 09:25:23.094 INFO [restartedMain] [InstanceInfoFactory] Setting initial instance status as: STARTING
2018-01-30 09:25:23.128 INFO [restartedMain] [DiscoveryClient] Initializing Eureka in region us-east-1
2018-01-30 09:25:23.164 INFO [restartedMain] [DiscoveryJerseyProvider] Using JSON encoding codec LegacyJacksonJson
2018-01-30 09:25:23.164 INFO [restartedMain] [DiscoveryJerseyProvider] Using JSON decoding codec LegacyJacksonJson
2018-01-30 09:25:23.230 INFO [restartedMain] [DiscoveryJerseyProvider] Using XML encoding codec XStreamXml
2018-01-30 09:25:23.230 INFO [restartedMain] [DiscoveryJerseyProvider] Using XML decoding codec XStreamXml
2018-01-30 09:25:23.360 INFO [restartedMain] [ConfigClusterResolver] Resolving eureka endpoints via configuration
2018-01-30 09:25:23.393 INFO [restartedMain] [DiscoveryClient] Disable delta property : false
2018-01-30 09:25:23.393 INFO [restartedMain] [DiscoveryClient] Single vip registry refresh property : null
2018-01-30 09:25:23.393 INFO [restartedMain] [DiscoveryClient] Force full registry fetch : false
2018-01-30 09:25:23.393 INFO [restartedMain] [DiscoveryClient] Application is null : false
2018-01-30 09:25:23.393 INFO [restartedMain] [DiscoveryClient] Registered Applications size is zero : true
2018-01-30 09:25:23.393 INFO [restartedMain] [DiscoveryClient] Application version is -1: true
2018-01-30 09:25:23.393 INFO [restartedMain] [DiscoveryClient] Getting all instance registry info from the eureka server
2018-01-30 09:25:23.434 INFO [restartedMain] [DiscoveryClient] The response status is 200
2018-01-30 09:25:23.435 INFO [restartedMain] [DiscoveryClient] Starting heartbeat executor: renew interval is: 30
2018-01-30 09:25:23.436 INFO [restartedMain] [InstanceInfoReplicator] InstanceInfoReplicator onDemand update allowed rate per min is 4
2018-01-30 09:25:23.439 INFO [restartedMain] [DiscoveryClient] Discovery Client initialized at timestamp 1517304323439 with initial instances count: 0
2018-01-30 09:25:23.442 INFO [restartedMain] [EurekaServiceRegistry] Registering application <app-name> with eureka with status UP
2018-01-30 09:18:53.450 INFO [restartedMain] [Http11NioProtocol] Initializing ProtocolHandler ["http-nio-9100"]
2018-01-30 09:18:53.453 INFO [DiscoveryClient-InstanceInfoReplicator-0] [DiscoveryClient] DiscoveryClient_<app-name>/<host>:<app-name>:9100 - registration status: 204
2018-01-30 09:18:53.457 INFO [restartedMain] [Http11NioProtocol] Starting ProtocolHandler ["http-nio-9100"]
2018-01-30 09:18:53.464 INFO [restartedMain] [NioSelectorPool] Using a shared selector for servlet write/read
2018-01-30 09:18:53.486 INFO [restartedMain] [TomcatWebServer] Tomcat started on port(s): 9100 (http) with context path ''
2018-01-30 09:18:53.487 INFO [restartedMain] [EurekaAutoServiceRegistration] Updating port to 9100
2018-01-30 09:18:53.490 INFO [restartedMain] [<app-name>] Started <app-name> in 7.427 seconds (JVM running for 7.999)
2018-01-30 09:18:53.524 WARN [restartedMain] [DiscoveryClient] Saw local status change event StatusChangeEvent [timestamp=1517303933524, current=DOWN, previous=UP]
2018-01-30 09:18:53.524 INFO [DiscoveryClient-InstanceInfoReplicator-0] [DiscoveryClient] DiscoveryClient_<app-name>/<host>:<app-name>:9100: registering service...
2018-01-30 09:18:53.535 INFO [restartedMain] [DiscoveryClient] Shutting down DiscoveryClient ...
2018-01-30 09:18:53.536 INFO [restartedMain] [DiscoveryClient] Unregistering ...
2018-01-30 09:18:53.538 INFO [DiscoveryClient-InstanceInfoReplicator-0] [DiscoveryClient] DiscoveryClient_<app-name>/<host>:<app-name>:9100 - registration status: 204
2018-01-30 09:18:53.542 INFO [restartedMain] [DiscoveryClient] DiscoveryClient_<app-name>/<host>:<app-name>:9100 - deregister status: 200
2018-01-30 09:18:53.549 INFO [restartedMain] [DiscoveryClient] Completed shut down of DiscoveryClient
来自eureka服务器的日志
2018-01-30 09:18:15.373 INFO 10804 --- [nio-8761-exec-8] c.n.e.registry.AbstractInstanceRegistry : Registered instance <app-name>/<host>:<app-name>:9100 with status UP (replication=false)
2018-01-30 09:18:15.383 INFO 10804 --- [nio-8761-exec-9] c.n.e.registry.AbstractInstanceRegistry : Registered instance <app-name>/<host>:<app-name>:9100 with status DOWN (replication=false)
2018-01-30 09:18:15.400 INFO 10804 --- [io-8761-exec-10] c.n.e.registry.AbstractInstanceRegistry : Cancelled instance <app-name>/<host>:<app-name>:9100 (replication=false)
2018-01-30 09:18:15.976 INFO 10804 --- [nio-8761-exec-2] c.n.e.registry.AbstractInstanceRegistry : Registered instance <app-name>/<host>:<app-name>:9100 with status DOWN (replication=true)
2018-01-30 09:18:15.977 INFO 10804 --- [nio-8761-exec-2] c.n.e.registry.AbstractInstanceRegistry : Cancelled instance <app-name>/<host>:<app-name>:9100 (replication=true)
2018-01-30 09:18:46.854 INFO 10804 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 0ms
谢谢你的帮助
我有相同的配置和你的,我也得到发现客户端关机问题。加法
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
在pom.xml中解决了我的问题。
希望它对你也有用。但我仍在试图弄清楚为什么在我跟随spring cloud课程构建应用程序时,课程作者没有特别添加“Spring-boot-starter-web”。
如何包含Eureka服务器 要在项目中包含Eureka服务器,请使用组org.springframework.cloud和工件id spring-cloud-starter-eureka-server的启动器。有关 使用当前的Spring Cloud发布列表设置构建系统的详细信息,请参阅Spring Cloud项目页面。 如何运行Eureka服务器 示例eureka服务器; @SpringBoot
我正在尝试建立一个基于Spring功能的简单微服务架构。我有3个简单的微服务作为起点:1配置服务器(Spring cloud config)2发现服务器(eureka Server)3网关Zuul 我配置了这些服务,以便发现服务器存储所有的.properties文件,它将自己注册到发现服务器,以便所有其他服务检索.properties文件,而不是通过静态url而是通过eureka服务器访问发现。
我一直在试图找到一个与eureka服务器集成的spring cloud gateway的运行示例,以及一些Hystrix示例,但到目前为止我还没有找到。有什么地方可以找到它吗?我真的很想看到spring cloud gateway投入使用,取代我目前的Zuul API服务。 谢谢!
在本章中,您将详细了解如何将Spring Boot Micro服务应用程序注册到Eureka Server中。 在注册应用程序之前,请确保Eureka Server在端口8761上运行或首先构建Eureka Server并运行它。 有关构建Eureka服务器的更多信息,请参阅上一章。 首先,您需要在我们的构建配置文件中添加以下依赖项,以便向Eureka服务器注册微服务。 Maven用户可以将以下依
pom.xml 主应用程序类 Application.Properties eureka客户端设置 pom.xml Application.Properties 我在eureka-server仪表板(http://localhost:8761)中没有看到向Eureka server注册的micro-service-currency-exchange-service 为什么eureka客户端没有注册
使用Spring Boot V1.5.x,可以将单个服务double用作Spring Boot Admin服务器和Eureka Discovery服务器。对于Spring Boot2.x,Spring Boot Admin Server似乎使用Spring reactive API(webflux,Netty Server等),而Netflix Eureka Discovery Server仍然使