Closing org.springframework.context.annotation.AnnotationConfigApplicationContext

本文解决了一个关于SpringBoot项目启动后自动关闭的问题,通过检查POM.xml文件,发现spring-boot-starter-web依赖中移除了Tomcat。在尝试打成WAR包时遇到此问题,通过注释掉相关代码并手动更新Maven项目,最终解决了启动失败的情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Spring boot 启动后自动关闭,log输出

Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@2c104774: startup date [Thu Aug 16 11:23:04 CST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@6531a794
Unregistering JMX-exposed beans on shutdown
Unregistering JMX-exposed beans

检查POM.xml 发现 spring-boot-starter-web 中移除了Tomcat, 这是在实验打成war包是的坑

在这里插入图片描述
将上面红框处注释掉后,再次尝试启动发现还是不行
原因是,删除后Maven并没有对项目进行UPDATE,手动对项目UPDATE后,再次启动问题解决了。

14:06:01.565 [main] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - [refresh,599] - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productInformationController': Unsatisfied dependency expressed through field 'productInformationService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productInformationServiceImpl': Unsatisfied dependency expressed through field 'rabbitMqService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.aerors.common.mq.service.RabbitMqService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 14:06:01.570 [main] WARN o.s.c.a.AnnotationConfigApplicationContext - [doClose,1075] - Exception thrown from ApplicationListener handling ContextClosedEvent org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'rabbitConnectionFactory': 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:220) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:214) at org.springframework.context.event.AbstractApplicationEventMulticaster.retrieveApplicationListeners(AbstractApplicationEventMulticaster.java:264) at org.springframework.context.event.AbstractApplicationEventMulticaster.getApplicationListeners(AbstractApplicationEventMulticaster.java:221) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:140) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:430) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:436) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:387) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1072) at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1035) at org.springframework.cloud.context.named.NamedContextFactory.destroy(NamedContextFactory.java:99) at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:213) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:587) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:559) at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:1163) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:520) at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:1156) at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1123) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:604) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:409) at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1289) at com.aerors.interpretation.AerorsInterpretationApplication.main(AerorsInterpretationApplication.java:20) 14:06:01.572 [main] INFO c.b.d.d.DynamicRoutingDataSource - [destroy,215] - dynamic-datasource start closing .... 14:06:01.574 [main] INFO c.a.d.p.DruidDataSource - [close,2204] - {dataSource-1} closing ... 14:06:01.577 [main] INFO c.a.d.p.DruidDataSource - [close,2277] - {dataSource-1} closed 14:06:01.577 [main] INFO c.b.d.d.d.DefaultDataSourceDestroyer - [destroy,98] - dynamic-datasource close the datasource named [master] success, 14:06:01.577 [main] INFO c.b.d.d.DynamicRoutingDataSource - [destroy,219] - dynamic-datasource all closed success,bye 14:06:01.578 [main] INFO o.a.c.c.StandardService - [log,173] - Stopping service [Tomcat] 14:06:01.629 [main] ERROR o.s.b.d.LoggingFailureAnalysisReporter - [report,40] - *************************** APPLICATION FAILED TO START *************************** Description: Field rabbitMqService in com.aerors.interpretation.service.impl.ProductInformationServiceImpl required a bean of type 'com.aerors.common.mq.service.RabbitMqService' that could not be found. The injection point has the following annotations: - @org.springframework.beans.factory.annotation.Autowired(required=true) Action: Consider defining a bean of type 'com.aerors.common.mq.service.RabbitMqService' in your configuration.
最新发布
07-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值