天天看點

解決Singleton bean creation not allowed while singletons of this factory are in destruction (Do not re

環境:springcloud F版本+maven工程

注冊中心正常,建立普通的client項目,向注冊中心注冊,啟動項目失敗。

解決控制台警告錯誤資訊:

Invocation of destroy method failed on bean with name 'scopedTarget.eurekaClient': org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'eurekaInstanceConfigBean': 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!)

首先檢查pom檔案是否有:

<dependency>

  <groupId>org.springframework.boot</groupId>

  <artifactId>spring-boot-starter-web</artifactId>

</dependency>

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>      

然後檢查啟動類是否添加了

@EnableDiscoveryClient      

注解。

繼續閱讀