Eureka服务器无法检测AWS

时间:2017-03-29 04:22:36

标签: spring amazon-web-services netflix-eureka spring-cloud-netflix

我正在尝试在AWS中运行Eureka服务器。

我创建了一个使用@EnableEurekaServer注释的Springboot应用程序,但每当应用程序在AWS中启动时,我都会收到以下日志消息:

2017-03-29 04:11:39.886  INFO 19046 --- [      Thread-10] o.s.c.n.e.server.EurekaServerBootstrap   : isAws returned false

担心我在我的应用中做错了什么我尝试了来自https://github.com/spring-cloud-samples/eureka.git的Eureka Spring云样本

我有完全相同的问题 - 即使我在EC2实例上运行,Eureka也未能检测到这一点。

服务器本身确实启动但它忽略了我所有的AWS特定配置,例如EIP绑定。

以下是运行mvn clean spring-boot:run

的完整日志输出
[INFO] --- spring-boot-maven-plugin:1.4.3.RELEASE:run (default-cli) @ eureka ---
2017-03-29 04:17:16.178  INFO 19466 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@1a19b36d: startup date [Wed Mar 29 04:17:16 UTC 2017]; root of context hierarchy
2017-03-29 04:17:16.575  INFO 19466 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2017-03-29 04:17:16.607  INFO 19466 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$2d153893] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

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

2017-03-29 04:17:16.927  INFO 19466 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://localhost:8888
2017-03-29 04:17:17.006  WARN 19466 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/eureka/default": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)
2017-03-29 04:17:17.007  INFO 19466 --- [           main] eurekademo.EurekaApplication             : No active profile set, falling back to default profiles: default
2017-03-29 04:17:17.020  INFO 19466 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5a6e74a7: startup date [Wed Mar 29 04:17:17 UTC 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@1a19b36d
2017-03-29 04:17:17.715  WARN 19466 --- [           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'.
2017-03-29 04:17:17.852  INFO 19466 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=512ba4fc-847f-3775-a8eb-3c9786c9462f
2017-03-29 04:17:17.899  INFO 19466 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2017-03-29 04:17:17.931  INFO 19466 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$2d153893] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-29 04:17:18.149  INFO 19466 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8761 (http)
2017-03-29 04:17:18.159  INFO 19466 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2017-03-29 04:17:18.160  INFO 19466 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.6
2017-03-29 04:17:18.246  INFO 19466 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2017-03-29 04:17:18.247  INFO 19466 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1227 ms
2017-03-29 04:17:18.608  INFO 19466 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'metricsFilter' to: [/*]
2017-03-29 04:17:18.608  INFO 19466 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-03-29 04:17:18.608  INFO 19466 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-03-29 04:17:18.608  INFO 19466 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-03-29 04:17:18.609  INFO 19466 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2017-03-29 04:17:18.609  INFO 19466 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'webRequestTraceFilter' to: [/*]
2017-03-29 04:17:18.609  INFO 19466 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'servletContainer' to urls: [/eureka/*]
2017-03-29 04:17:18.609  INFO 19466 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'applicationContextIdFilter' to: [/*]
2017-03-29 04:17:18.609  INFO 19466 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2017-03-29 04:17:18.677  INFO 19466 --- [ost-startStop-1] c.s.j.s.i.a.WebApplicationImpl           : Initiating Jersey application, version 'Jersey: 1.19.1 03/11/2016 02:08 PM'
2017-03-29 04:17:18.732  INFO 19466 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2017-03-29 04:17:18.733  INFO 19466 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2017-03-29 04:17:18.819  INFO 19466 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2017-03-29 04:17:18.820  INFO 19466 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2017-03-29 04:17:19.119  INFO 19466 --- [           main] o.s.c.n.eureka.InstanceInfoFactory       : Setting initial instance status as: STARTING
2017-03-29 04:17:19.159  INFO 19466 --- [           main] com.netflix.discovery.DiscoveryClient    : Client configured to neither register nor query for data.
2017-03-29 04:17:19.167  INFO 19466 --- [           main] com.netflix.discovery.DiscoveryClient    : Discovery Client initialized at timestamp 1490761039167 with initial instances count: 0
2017-03-29 04:17:19.231  INFO 19466 --- [           main] c.n.eureka.DefaultEurekaServerContext    : Initializing ...
2017-03-29 04:17:19.233  INFO 19466 --- [           main] c.n.eureka.cluster.PeerEurekaNodes       : Adding new peer nodes [http://localhost:8761/eureka/]
2017-03-29 04:17:19.339  INFO 19466 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2017-03-29 04:17:19.339  INFO 19466 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2017-03-29 04:17:19.339  INFO 19466 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2017-03-29 04:17:19.339  INFO 19466 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2017-03-29 04:17:19.432  INFO 19466 --- [           main] c.n.eureka.cluster.PeerEurekaNodes       : Replica node URL:  http://localhost:8761/eureka/
2017-03-29 04:17:19.440  INFO 19466 --- [           main] c.n.e.registry.AbstractInstanceRegistry  : Finished initializing remote region registries. All known remote regions: []
2017-03-29 04:17:19.440  INFO 19466 --- [           main] c.n.eureka.DefaultEurekaServerContext    : Initialized
2017-03-29 04:17:20.003  INFO 19466 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5a6e74a7: startup date [Wed Mar 29 04:17:17 UTC 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@1a19b36d
2017-03-29 04:17:20.093  INFO 19466 --- [           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>)
2017-03-29 04:17:20.094  INFO 19466 --- [           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>)
2017-03-29 04:17:20.096  INFO 19466 --- [           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)
2017-03-29 04:17:20.096  INFO 19466 --- [           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)
2017-03-29 04:17:20.125  INFO 19466 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-03-29 04:17:20.125  INFO 19466 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-03-29 04:17:20.158  INFO 19466 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-03-29 04:17:20.562  INFO 19466 --- [           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>)
2017-03-29 04:17:20.562  INFO 19466 --- [           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()
2017-03-29 04:17:20.564  INFO 19466 --- [           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()
2017-03-29 04:17:20.565  INFO 19466 --- [           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)
2017-03-29 04:17:20.565  INFO 19466 --- [           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()
2017-03-29 04:17:20.566  INFO 19466 --- [           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
2017-03-29 04:17:20.566  INFO 19466 --- [           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()
2017-03-29 04:17:20.566  INFO 19466 --- [           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()
2017-03-29 04:17:20.567  INFO 19466 --- [           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()
2017-03-29 04:17:20.568  INFO 19466 --- [           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()
2017-03-29 04:17:20.569  INFO 19466 --- [           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)
2017-03-29 04:17:20.569  INFO 19466 --- [           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()
2017-03-29 04:17:20.571  INFO 19466 --- [           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)
2017-03-29 04:17:20.571  INFO 19466 --- [           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()
2017-03-29 04:17:20.572  INFO 19466 --- [           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()
2017-03-29 04:17:20.574  INFO 19466 --- [           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()
2017-03-29 04:17:20.575  INFO 19466 --- [           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()
2017-03-29 04:17:20.575  INFO 19466 --- [           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()
2017-03-29 04:17:20.575  INFO 19466 --- [           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()
2017-03-29 04:17:20.576  INFO 19466 --- [           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()
2017-03-29 04:17:20.576  INFO 19466 --- [           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()
2017-03-29 04:17:20.669  INFO 19466 --- [           main] o.s.ui.freemarker.SpringTemplateLoader   : SpringTemplateLoader for FreeMarker: using resource loader [org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5a6e74a7: startup date [Wed Mar 29 04:17:17 UTC 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@1a19b36d] and template loader path [classpath:/templates/]
2017-03-29 04:17:20.670  INFO 19466 --- [           main] o.s.w.s.v.f.FreeMarkerConfigurer         : ClassTemplateLoader for Spring macros added to FreeMarker configuration
2017-03-29 04:17:20.744  WARN 19466 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2017-03-29 04:17:20.744  INFO 19466 --- [           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.
2017-03-29 04:17:20.749  WARN 19466 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2017-03-29 04:17:20.749  INFO 19466 --- [           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.
2017-03-29 04:17:20.816  INFO 19466 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-03-29 04:17:20.823  INFO 19466 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'refreshScope' has been autodetected for JMX exposure
2017-03-29 04:17:20.824  INFO 19466 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'environmentManager' has been autodetected for JMX exposure
2017-03-29 04:17:20.826  INFO 19466 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'configurationPropertiesRebinder' has been autodetected for JMX exposure
2017-03-29 04:17:20.826  INFO 19466 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'refreshEndpoint' has been autodetected for JMX exposure
2017-03-29 04:17:20.827  INFO 19466 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'restartEndpoint' has been autodetected for JMX exposure
2017-03-29 04:17:20.829  INFO 19466 --- [           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]
2017-03-29 04:17:20.840  INFO 19466 --- [           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]
2017-03-29 04:17:20.849  INFO 19466 --- [           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]
2017-03-29 04:17:20.856  INFO 19466 --- [           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=5a6e74a7,type=ConfigurationPropertiesRebinder]
2017-03-29 04:17:20.861  INFO 19466 --- [           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]
2017-03-29 04:17:21.053  INFO 19466 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
2017-03-29 04:17:21.067  INFO 19466 --- [           main] c.n.e.EurekaDiscoveryClientConfiguration : Registering application eureka with eureka with status UP
2017-03-29 04:17:21.070  INFO 19466 --- [      Thread-10] o.s.c.n.e.server.EurekaServerBootstrap   : Setting the eureka configuration..
2017-03-29 04:17:21.070  INFO 19466 --- [      Thread-10] o.s.c.n.e.server.EurekaServerBootstrap   : Eureka data center value eureka.datacenter is not set, defaulting to default
2017-03-29 04:17:21.070  INFO 19466 --- [      Thread-10] o.s.c.n.e.server.EurekaServerBootstrap   : Eureka environment value eureka.environment is not set, defaulting to test
2017-03-29 04:17:21.097  INFO 19466 --- [      Thread-10] o.s.c.n.e.server.EurekaServerBootstrap   : isAws returned false
2017-03-29 04:17:21.098  INFO 19466 --- [      Thread-10] o.s.c.n.e.server.EurekaServerBootstrap   : Initialized server context
2017-03-29 04:17:21.098  INFO 19466 --- [      Thread-10] c.n.e.r.PeerAwareInstanceRegistryImpl    : Got 1 instances from neighboring DS node
2017-03-29 04:17:21.098  INFO 19466 --- [      Thread-10] c.n.e.r.PeerAwareInstanceRegistryImpl    : Renew threshold is: 1
2017-03-29 04:17:21.098  INFO 19466 --- [      Thread-10] c.n.e.r.PeerAwareInstanceRegistryImpl    : Changing status to UP
2017-03-29 04:17:21.105  INFO 19466 --- [      Thread-10] e.s.EurekaServerInitializerConfiguration : Started Eureka Server
2017-03-29 04:17:21.154  INFO 19466 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8761 (http)
2017-03-29 04:17:21.155  INFO 19466 --- [           main] c.n.e.EurekaDiscoveryClientConfiguration : Updating port to 8761
2017-03-29 04:17:21.158  INFO 19466 --- [           main] eurekademo.EurekaApplication             : Started EurekaApplication in 5.439 seconds (JVM running for 8.49)
2017-03-29 04:17:26.523  INFO 19466 --- [nio-8761-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2017-03-29 04:17:26.523  INFO 19466 --- [nio-8761-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2017-03-29 04:17:26.534  INFO 19466 --- [nio-8761-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 11 ms

我认为如果isAws等于true,那么我的问题就会得到解决,但是关于为什么Eureka认为它没有在AWS中运行,即使它存在,也没有其他细节。

我也尝试将参数-Deureka.datacenter = cloud传递给无效。

要测试这个,只需启动任何ec2实例(在我的情况下是t2.medium),安装git和maven(java8应该已经安装),checkout https://github.com/spring-cloud-samples/eureka.git,运行sprintboot app。

1 个答案:

答案 0 :(得分:2)

所以我想通了。

开箱即用,Springboot Eureka不包含所需的依赖关系,如果它在AWS中,则不会。

我在POM中添加了以下内容:

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-aws-autoconfigure</artifactId>
        <version>1.2.1.RELEASE</version>
    </dependency>

一旦我做完了,那么Eureka就能确定它是在AWS中。

请注意,我认为您可以使用此依赖项 - 我认为所需的只是AWS ec2依赖项com.amazonaws/aws-java-sdk-ec2,但我从未对此进行过测试。