1. 程式人生 > >spring boot-部署時報org.springframework.beans.factory.BeanCreationNotAllowedException異常

spring boot-部署時報org.springframework.beans.factory.BeanCreationNotAllowedException異常

今天在本機測試的時候,一直報這個異常:

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>

該依賴包的主要作用是測試的時候,修改配置或程式碼可以自動實現熱部署,然而在多例項測試的時候,就會報上面的異常,使用需謹慎啊!