has been injected into other beans[XXXXXXXXXX] in its raw version as part of a circular reference
Posted leng39
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了has been injected into other beans[XXXXXXXXXX] in its raw version as part of a circular reference相关的知识,希望对你有一定的参考价值。
最近项目在重构,代码层面的优化,然后从svn更新代码之后,启动tomcat报出下面这个异常
找了很久,试了很多方法,比如懒加载,没作用,查找spring配置文件,也没问题,最后发现了spring的循环依赖,就是ServiceA 引用 ServiceB,ServiceB又引用了 ServiceA ,如果代码这样写,spring在初始化的时候根本不知道要把哪个bean装入容器,导致bean加载失败
实际上在代码设计的时候,就不能这样写,尽量做到解耦,抽出公共部分新建一个service,因为我这边SericeA只有一个方法引用到了ServiceB,所以我把这个方法写进了ServiceB,然后去掉了@Autowire ServiceB,这样就不会报错啦!!!!
最后啰嗦一句,因为我不经常写博客,今天有空,刚好碰到问题就记录下来了,各位大佬手下留情哈!!!!
以上是关于has been injected into other beans[XXXXXXXXXX] in its raw version as part of a circular reference的主要内容,如果未能解决你的问题,请参考以下文章
has been injected into other beans[XXXXXXXXXX] in its raw version as part of a circular reference
USING CURRENT LOGFILE has been deprecated