tomcat部署多工程Singleton bean creation not allowed while the singletons of this factory are in destructi

场景:同一个tomcat下部署多个java工程。

问题现象: 启动tomcat时报异常Singleton bean creation not allowed while the singletons of this factory are in destruction

问题原因:不同的工程分别创建了同一个单例。

处理方案:1、在应用的web.xml文件中,配置不同的webAppRootKey,<param-value>值可以自定义,只要相同tomcat下的各个工程保持不同即可。

  1. <context-param>  
  2.   <param-name>webAppRootKey</param-name>  
  3.   <param-value>web.sample.root</param-value>  
  4. </context-param>  

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
出现错误信息"Singleton bean creation not allowed while the singletons of this factory are in destruction"通常是因为在Spring容器销毁过程中,尝试创建了单例Bean。根据引用和引用的描述,这个错误通常发生在使用线程池进行Spring任务测试时。 具体地说,当Spring容器正在销毁阶段时,不允许再次请求创建单例Bean。这是因为在销毁过程中,容器会依次销毁已创建的单例Bean,如果允许在此期间创建新的单例Bean,可能会导致不一致的状态。 这个问题可能是由于代码中的某个地方在销毁阶段调用了BeanFactory的方法,例如在destroy方法的实现中请求了一个Bean。这样的调用是不被支持的,因为在销毁期间,容器已经不再接受新的Bean创建请求。 为了解决这个问题,需要检查代码中是否存在在销毁阶段请求创建Bean的情况。如果确实需要在销毁过程中使用Bean,可以考虑使用非单例Bean或者使用ApplicationContextAware接口获取ApplicationContext来避免使用BeanFactory。 总结来说,当出现Spring启动错误"Singleton bean creation not allowed while the singletons of this factory are in destruction"时,通常是因为在容器销毁阶段请求创建了单例Bean,需要检查代码中是否存在这样的情况并进行相应的修改。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [SpringBoot 启动失败:Singleton bean creation not allowed while singletons of this factory are in ...](https://blog.csdn.net/m0_37787662/article/details/102842488)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [spring启动错误Singleton bean creation not allowed while the singletons of this factory are in...](https://blog.csdn.net/chenwiehuang/article/details/101532591)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值