0
点赞
收藏
分享

微信扫一扫

【Exception】The dependencies of some of the beans in the application context form a cycle


案发现场

***************************
APPLICATION FAILED TO START
***************************

Description:

The dependencies of some of the beans in the application context form a cycle:

┌─────┐
|  asyncConfig defined in file [E:\code\spring-boot-demo\target\classes\com\itplh\config\AsyncConfig.class]
└─────┘

原因分析

@Configuration
public class AsyncConfig {

    private AsyncConfig asyncConfig;

    public AsyncConfig(AsyncConfig asyncConfig) {
        this.asyncConfig = asyncConfig;
    }

}

用了构造器注入当前类,导致循环依赖

解决方案

使用 set注入

@Configuration
public class AsyncConfig {
	
	@Autowired
    private AsyncConfig asyncConfig;

}


举报

相关推荐

0 条评论