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-09-03 13:57:27

    load average 的含义

    一般的进程需要消耗CPU、内存、磁盘I/O、网络I/O等资源,在这种情况下,平均负载就不是单独指的CPU使用情况。即内存、磁盘、网络等因素也可以影响系统的平均负载值。 在单核处理器中,平均负载值为1或者小于1的时候,系统处理进程会非常轻松,即负载很低。当达到3的时候,就会显得很忙,达到5或者8的时候就不能很好的处理进程了(其中5和8目前还是个争议的阈值,为了保守起见,建议选择低的)。

  • 2018-09-05 01:42:03

    git reset 回退以前某个版本及常用命令

    第一个命令只删除所有untracked的文件,如果文件已经被tracked, 修改过的文件不会被回退。而第二个命令把tracked的文件revert到前一个版本,对于untracked的文件(比如编译的临时文件)都不会被删除。

  • 2018-09-08 16:04:25

    Android SQLiteDatabase使用详细教程

    Android提供了创建和是用SQLite数据库的API。SQLiteDatabase代表一个数据库对象,提供了操作数据库的一些方法。在Android的SDK目录下有sqlite3工具,我们可以利用它创建数据库、创建表和执行一些SQL语句。下面是SQLiteDatabase的常用方法。SQLiteDatabase的常用方法方法名称方法表示含义openOrCreateDatabase(Stringpath,SQLiteDatabase.CursorFactoryfactory)

  • 2018-09-09 02:25:09

    单例模式的好处和缺点?为什么要用单例模式?

    单例模式是一种常用的软件设计模式。在它的核心结构中只包含一个被称为单例类的特殊类。通过单例模式可以保证系统中一个类只有一个实例而且该实例易于外界访问,从而方便对实例个数的控制并节约系统资源。如果希望在系统中某个类的对象只能存在一个,单例模式是最好的解决方案。

  • 2018-09-09 02:31:48

    基于VCamera,仿微信录制短视频

    基于VCamera,Android仿微信录制短视频,如果喜欢请star,如果觉得有纰漏请提交issue,如果你有更好的点子可以提交pull request。