一、该问题的重现步骤是什么?
1. 业务模块中,引入xxl-job-core后,初始化
XxlJobConfig类中
@Bean
public XxlJobSpringExecutor xxlJobExecutor() {
logger.info(">>>>>>>>>>> xxl-job config init.");
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
xxlJobSpringExecutor.setAppName(appname);
xxlJobSpringExecutor.setIp(ip);
xxlJobSpringExecutor.setPort(port);
xxlJobSpringExecutor.setAccessToken(accessToken);
xxlJobSpringExecutor.setLogPath(logPath);
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
return xxlJobSpringExecutor;
}启动时会出现循环依赖报错,
The dependencies of some of the beans in the application context form a cycle:
┌──->──┐
| xxlJobExecutor defined in class path resource [org/springblade/xpc/executor/config/XxlJobConfig.class]
└──<-──┘
2.看案例,加入了允许spring的循环依赖,如下
: : :
启动正常;
二、请问下blade框架,是做了什么会引起这样的错误?单看XxlJobConfig类的代码,很难理解会用循环依赖的问题,请指教谢谢
参考biz项目的例子。
![1700127306817007.png ~FG5(T67LYWR9J_3DKY]FTO.png](/data/ueditor/php/upload/image/20231116/1700127306817007.png)
我看解决方式,是加spring配置 allow-circular-references: true
但为什么blade框架会产生这样的问题,会不会有其它不可知的隐患?
而且看pom文件没意义,不是引用的问题,是blade框架的问题
因为bladex自带的例子也是引入了xxl-job-core,但是没有你说的这个错,
所以不是bladex做了什么导致这个错,而是你引入了这个依赖外还做了哪些改动才导致的这个错。
我们需要看到你具体的改动以及具体的依赖才好找原因。
如下截图,就blade的demo,我把允许spring循环依赖的给注释掉,也报循环依赖错误,所以还是框架那有问题

注意看红框截图,删掉了所有的blade依赖,只保留最基础的4个非blade依赖,作为一个纯原生的springboot服务来看,依旧有这个错误,那么很显然了,是xxl-job本身的问题。
因为blade的任何依赖都没有了也就是说不是blade的封装引起的。



补充:xxlCofig的代码是拷贝xxljob官方demo的代码,加上循环依赖的配置后可以解决这个问题
扫一扫访问 Blade技术社区 移动端