【问题标题】:Failed to start project sometimes,report an error : unresolvable circular reference有时启动项目失败,报错:无法解析的循环引用
【发布时间】:2020-06-16 14:42:20
【问题描述】:

我们有时启动项目失败,当然大多数时候启动成功。失败时报错:

[AbstractApplicationContext.java] refresh : 487 -- Exception encountered during context initialization - cancelling refresh attempt 
org.springframework.beans.factory.BeanCurrentlyInCreationException: 
Error creating bean with name 'ITsysDesktopConfig': 
Requested bean is currently in creation: 
Is there an unresolvable circular reference?

我确定没有循环引用。

使用的是Spring版本4.1.1.RELEASE,我使用的是Spring XML文件,项目中没有注解

当我使用更高配置的电脑时,发生错误的可能性较小。

【问题讨论】:

    标签: spring


    【解决方案1】:

    问题可能出在

    @ComponentScan(basePackages = "com.my.app")

    尝试改变

    @ComponentScan(basePackages = "com.my.app")

    @ComponentScan(basePackages = {"com.my.app.service", "com.my.app.config", "com.my.app"})

    我认为这是 bean 加载器的 Spring 问题...

    参考:

    1. https://github.com/spring-projects/spring-boot/issues/6045
    2. https://jira.spring.io/browse/SPR-14307
    3. Why does Spring get circular dependency issues on one machine and not another?
    4. https://www.logicbig.com/tutorials/spring-framework/spring-core/circular-dependencies.html

    【讨论】:

    • 我减少了DAO中的接口,一切正常,但我仍然不知道为什么
    猜你喜欢
    • 2021-10-17
    • 1970-01-01
    • 1970-01-01
    • 2022-01-14
    • 1970-01-01
    • 2020-12-20
    • 2011-08-26
    • 2017-04-14
    • 2015-11-20
    相关资源
    最近更新 更多