Spring报错:has been injected into other beans [xxx] in its raw version as part of a circular reference

2020-01-05 12:48:03

参考链接 Spring报错:has been injected into other beans [xxx] in its raw version as part of a circular reference

一、问题描述


在启动项目时,遇到Spring报错,但不影响正常使用,经整理,报错信息如下:


org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'systemService': Bean with name 'systemService' has been injected into other beans [yeeDoctorsImpactService] in its raw version as part of a circular reference, but has eventually been wrapped. This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example.


 


二、项目简述


1、 SSM结构, Spring 全家桶4.3+ 。


2、使用 @Autowired 注解注入需要用到的 Service 。


 


三、问题解决


1、原因: systemService 类中注入了 yeeDoctorsImpactService , 而在 yeeDoctorsImpactService 类中也注入了 systemService ,从而引起该异常。 (循环引用)


2、解决: systemService 类注入 yeeDoctorsImpactService 时,增加注解 @Lazy ,反之同理。


3、@Lazy 注解路径为: org.springframework.context.annotation.Lazy 。


 

  • 2020-03-06 22:28:05

    git中submodule子模块的添加、使用和删除

    执行成功后,git status会看到项目中修改了.gitmodules,并增加了一个新文件(为刚刚添加的路径) git diff --cached查看修改内容可以看到增加了子模块,并且新文件下为子模块的提交hash摘要 git commit提交即完成子模块的添加

  • 2020-03-09 21:34:48

    Android TV 包安装成功后找不到启动图标

    生成APK文件,用U盘插入到小米盒子上,然后点击安装,提示安装成功。 可是找不到启动图标,安装成功的弹窗也没有打开的选项。 而我之前测试装的一款手机应用是可以找到启动图标的。

  • 2020-03-09 21:37:10

    安卓Tv端App开发与手机端的开发的区别

    因为大部分电视机的配置一般都比手机低,但是电视机一般都是用来看视频的,所以在做视频解码的时候,因为电视机配置比较低,所以大多数手机运行流畅的播放器在电视机上面都会卡顿,或者出现一些其他的问题,经过我同事长时间的测试,认为百度播放器跟小米播放器比较适合电视机作为播放器开发使用。如果你们要选择一个播放器,要先拿一个demo去很多台不同类型的电视机去测试,因为网络上面的播放器在电视机卡的真的很多,先测试好了再使用可以节约大家的时间。

  • 2020-03-09 22:11:39

    聊聊真实的 Android TV 开发技术栈

    智能电视越来越普及了,华为说四月发布智能电视跳票了,一加也说今后要布局智能电视,在智能电视方向,小米已经算是先驱了。但是还有不少开发把智能电视简单的理解成手机屏幕的放大,其实这两者并不一样。