Spring出现Error creating bean with name and Singleton bean creation not allowed

来源:互联网 发布:如何解析json数组 编辑:程序博客网 时间:2024/05/16 15:36

出现这个错误的原因Singleton的对象已经被销毁了,然后随后被另一个线程访问了。

我出现这个问题的场景是:使用JUnit测试异步任务的时候,任务执行了,随后scheduler访问了一个Singleton的Bean,但是这个Bean实际已经被销毁了。

还有一个情况也可能会出现这个问题:多个tomcat instance在运行(Check if you have more than one tomcat's instance. 
if this is your case, shutdown all instance then open one and only one instance)。

0 0
原创粉丝点击