org.springframework.beans.factory.beancreationnotallowedexception: error cre
时间: 2023-10-28 07:54:01 浏览: 205
测试spring中的org.springframework.beans.factory.InitializingBean
ating bean with name 'beanName': Singleton bean creation not allowed while the singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
This exception is thrown when you attempt to create a new bean while the singleton beans of the factory are being destroyed. This is not allowed because it can cause problems with the destruction process of the existing beans.
The message suggests that you should not request a bean from a BeanFactory in a destroy method implementation. This means that if you have a method that is called during the destruction process of a bean, you should not use the BeanFactory to create a new bean.
Instead, you should either create the bean outside of the BeanFactory or use a different method to create the bean that is not called during the destruction process. Alternatively, you could refactor your code to avoid the need to create new beans during the destruction process.
To solve this issue, you can try the following steps:
1. Check if you are trying to create a new bean during the destruction process of a singleton bean.
2. Refactor your code to avoid the need to create new beans during the destruction process.
3. If you still need to create a bean during the destruction process, create it outside of the BeanFactory.
4. Use a different method to create the bean that is not called during the destruction process.
阅读全文