我正在开发Spring Boot + Microservices
示例。我已经从链接https://github.com/PacktPublishing/Mastering-Spring-Cloud/tree/master/Chapter06/sample-spring-cloud-comm-feign中获取了参考。
在此示例中,我能够成功启动discovery-service
和gateway-service
,但是当我尝试启动任何其他服务时,却遇到了错误。
我注意到一件事,即使书中没有明确提到,但指令如何执行也不是很清楚。请指导。
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
19:05:25.564 ERROR
***************************
APPLICATION FAILED TO START
***************************
Description:
The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured.
Action:
Verify the connector's configuration, identify and stop any process that's listening on port 8080, or configure this application to listen on another port.
19:05:25.564 INFO Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1992eaf4: startup date [Mon Dec 24 19:05:14 IST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@48aca48b
19:05:25.564 INFO Unregistering application customer-service with eureka with status DOWN
19:05:25.564 WARN Saw local status change event StatusChangeEvent [timestamp=1545658525564, current=DOWN, previous=UP]
19:05:25.564 INFO DiscoveryClient_CUSTOMER-SERVICE/localhost:customer-service: registering service...
19:05:25.564 INFO Stopping beans in phase 0
19:05:25.579 INFO DiscoveryClient_CUSTOMER-SERVICE/localhost:customer-service - registration status: 204
19:05:26.017 INFO Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@4a064404: startup date [Mon Dec 24 19:05:26 IST 2018]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1992eaf4
19:05:26.061 INFO JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
19:05:26.221 INFO Flipping property: localhost.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
19:05:26.221 INFO Shutdown hook installed for: NFLoadBalancer-PingTimer-localhost
19:05:26.254 INFO Client: localhost instantiated a LoadBalancer: DynamicServerListLoadBalancer:{NFLoadBalancer:name=localhost,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:null
19:05:26.288 INFO Using serverListUpdater PollingServerListUpdater
19:05:26.288 INFO DynamicServerListLoadBalancer for client localhost initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=localhost,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:org.springframework.cloud.netflix.ribbon.eureka.DomainExtractingServerList@1ba156fc
19:05:26.585 INFO Unregistering JMX-exposed beans on shutdown
19:05:26.585 INFO Unregistering JMX-exposed beans
19:05:26.585 INFO Shutting down DiscoveryClient ...
19:05:26.585 INFO Unregistering ...
19:05:26.606 INFO DiscoveryClient_CUSTOMER-SERVICE/localhost:customer-service - deregister status: 200
19:05:26.607 INFO Completed shut down of DiscoveryClient
19:05:26.607 INFO Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@4a064404: startup date [Mon Dec 24 19:05:26 IST 2018]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1992eaf4
19:05:26.607 WARN Exception thrown from ApplicationListener handling ContextClosedEvent
org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'eurekaAutoServiceRegistration': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:216)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1078)
at org.springframework.context.event.ApplicationListenerMethodAdapter.getTargetBean(ApplicationListenerMethodAdapter.java:283)
at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:253)
at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:177)
at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:140)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:399)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:991)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958)
at org.springframework.cloud.context.named.NamedContextFactory.destroy(NamedContextFactory.java:76)
at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:272)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:961)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.destroySingletons(FactoryBeanRegistrySupport.java:230)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968)
at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1030)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1006)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958)
at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:750)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134)
at pl.piomin.services.customer.CustomerApplication.main(CustomerApplication.java:22)
19:05:26.607 INFO Shutdown hook removed for: NFLoadBalancer-PingTimer-localhost
19:05:26.607 INFO Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@1491344a: startup date [Mon Dec 24 19:05:17 IST 2018]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1992eaf4
19:05:26.607 WARN Exception thrown from ApplicationListener handling ContextClosedEvent
org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'eurekaAutoServiceRegistration': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
答案 0 :(得分:0)
在具有以下属性的任何位置更改application.yml中的端口。在您的系统中,tomcat可能在默认的8080端口中运行。
服务器:
端口:$ {PORT:8080}
希望以上更改对您有所帮助。
答案 1 :(得分:0)
https://github.com/spring-cloud/spring-cloud-netflix/commit/12583fd0c25638f95c14973d921ca28cdcd17df5
将您的春季云版本更新为Greenwich.SR6,问题将会消失