专注于 JetBrains IDEA 全家桶,永久激活,教程
持续更新 PyCharm,IDEA,WebStorm,PhpStorm,DataGrip,RubyMine,CLion,AppCode 永久激活教程

BeanCreationNotAllowedException: Error creating bean with name 'eurekaInstanceCo

学习 SpringCloud 时遇到如下错误

Destroy method on bean with name 'scopedTarget.eurekaClient' threw an exception: 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!)

找了好久终于在 githubSpringCloud 的 issues 里找到了解决方案,链接在这里

网上也有很多文章说这样解决

@Component
public class FeignBeanFactoryPostProcessor implements BeanFactoryPostProcessor {

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        BeanDefinition bd = beanFactory.getBeanDefinition("feignContext");
        bd.setDependsOn("eurekaServiceRegistry", "inetUtils");
    }
}

但我用这个方法不行。

最终的解决方案是在 pom.xml 添加 spring-boot-starter-web 依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

然后重新导入完美解决。

所用的 SpringBoot 版本:2.1.0.M2

SpringCloud 版本:Greenwich.BUILD-SNAPSHOT

文章永久链接:https://tech.souyunku.com/44478

未经允许不得转载:搜云库技术团队 » BeanCreationNotAllowedException: Error creating bean with name 'eurekaInstanceCo

JetBrains 全家桶,激活、破解、教程

提供 JetBrains 全家桶激活码、注册码、破解补丁下载及详细激活教程,支持 IntelliJ IDEA、PyCharm、WebStorm 等工具的永久激活。无论是破解教程,还是最新激活码,均可免费获得,帮助开发者解决常见激活问题,确保轻松破解并快速使用 JetBrains 软件。获取免费的破解补丁和激活码,快速解决激活难题,全面覆盖 2024/2025 版本!

联系我们联系我们