内置junit测试执行时获取异常

时间:2018-10-06 03:25:00

标签: spring-boot reactive-programming spring-webflux junit5

  

任务:测试   线程“ Thread-24”中的异常java.lang.IllegalStateException:org.springframework.beans.factory.BeanCreationNotAllowedException:创建名称为“ traceApplicationContextRefreshedListener”的bean时出错:在破坏该工厂的singleton时,不允许创建singleton bean(不要请求销毁方法实现中的BeanFactory中的bean!)           在org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.stopAndReleaseReactiveWebServer(ReactiveWebServerApplicationContext.java:174)处           在org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.onClose(ReactiveWebServerApplicationContext.java:93)           在org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1023)           在org.springframework.context.support.AbstractApplicationContext $ 1.run(AbstractApplicationContext.java:937)   由以下原因引起:org.springframework.beans.factory.BeanCreationNotAllowedException:创建名称为'traceApplicationContextRefreshedListener'的bean时出错:在破坏该工厂的singleton时,不允许创建singleton bean(不要在destroy方法实现中向BeanFactory请求bean! )           在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:208)           在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)           在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:224)           在org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1012)           在org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:338)           在org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:333)           在org.springframework.cloud.sleuth.instrument.reactor.ReactorSleuth.contextRefreshed(ReactorSleuth.java:145)           在org.springframework.cloud.sleuth.instrument.reactor.ReactorSleuth.lambda $ null $ 2(ReactorSleuth.java:124)上           在reactor.core.publisher.MonoLift.subscribe(MonoLift.java:42)           在Reactor.core.publisher.Mono.block(Mono.java:1174)           在反应堆.ipc.netty.tcp.BlockingNettyContext.shutdown(BlockingNettyContext.java:152)           在org.springframework.boot.web.embedded.netty.NettyWebServer.stop(NettyWebServer.java:123)           在org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.stopAndReleaseReactiveWebServer(ReactiveWebServerApplicationContext.java:170)处           ...还有3个

1 个答案:

答案 0 :(得分:0)

出于某些原因,我可能会回想一下这个问题:

  1. JAVA_HOME环境变量设置正确的路径,更新PATH变量,然后重新启动eclipse / STS IDE,无论使用哪种方式。
  2. 另一个可能是您尝试运行JUnit测试用例时同时打开了多个Tomcat实例。您可以关闭所有这些实例,然后仅打开一个实例进行排序。

请仔细检查这些内容,让我知道它会有所帮助!