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 。


 

  • 2018-10-25 11:05:16

    SimpleDateFormat转换时间,12,24时间格式

    在使用SimpleDateFormat时格式化时间的 yyyy.MM.dd 为年月日而如果希望格式化时间为12小时制的,则使用hh:mm:ss 如果希望格式化时间为24小时制的,则使用HH:mm:ss

  • 2018-10-27 16:36:09

    关于 android 中 postDelayed方法的讲解

    当然,你也可以做一个闹钟提醒延时的函数试试,比如,先用MediaPlayer播放闹钟声音, 如果不想起,被停止播放之后,下次就5分钟后再播放,再被停止的话,下次就4分钟后播放,

  • 2018-10-27 17:24:45

    使用localstorage和预加载做到webview秒开

    提到网页加载速度优化,大家都会想到静态资源上CDN,CSS和JS文件合并,图片合并成雪碧图等常用手段;但是在某些特殊情况下这些常用方法也无法达到理想的效果。比如,在国际化场景下,很多国家还停留在2G网络阶段,无论如何优化,都无法避免过慢的网络请求。最近一直在做国际化(主要是印尼和泰国)背景下的webview性能优化,也算有一些经验。由于我们的产品是面向android用户的,而android手机对H5支持很好,因此我们主要是应用H5的新特性。

  • 2018-10-28 10:50:26

    VectorDrawable简单介绍

    在项目中使用矢量图至少可以缩小我们apk包的尺寸,而且可以在屏幕适配时提供很大的方便,因为矢量图是分辨率无关的。