spring boot-部署时报org.springframework.beans.factory.BeanCreationNotAllowedException异常

xiaoxiao2021-02-28  23

今天在本机测试的时候,一直报这个异常:

org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'org.springframework.cloud.netflix.eureka.EurekaDiscoveryClientConfiguration': 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!) 异常复现:

1、在本地启一个服务

2、更换端口号,然后再启一个服务

当启第二个服务的时候,结果就报上面那个异常

通过排查,发现是由于加入了下面的依赖造成的

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> 该依赖包的主要作用是测试的时候,修改配置或代码可以自动实现热部署,然而在多实例测试的时候,就会报上面的异常,使用需谨慎啊!

转载请注明原文地址: https://www.6miu.com/read-1100322.html

最新回复(0)