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-11-30 09:04:02

    js中set和get方法

    1. get和set是方法,因为是方法,所以可以进行判断 2. get一般是要返回的;而set是设置,不用返回 3. 如果调用对象内部的属性约定的命名方式是变量名前加_

  • 2020-12-01 16:10:12

    IntelliJ IDEA之代理配置 anyproxy

    网络号,真是太爽了,真的,如果又了好的网络,开发真是事半功倍,所以,大家开发前,一定要把自己的网络给整好。 会给你节省不少时间呢。

  • 2020-12-01 16:14:54

    HTTP状态码429的含义

    发生429是服务器接口并发太多引起的,可根据代码进行修改,放开限制次数

  • 2020-12-01 16:19:26

    vue中动画分布解析

    enter, enter-active, enter-active-to, (开始 进入阶段的)第1帧 属性值,到 (默认属性值 的过渡阶段),移除enter动画, leave, leave-active, leave-active-to (开始 离开 阶段的)第1帧 默认属性值,到 (属性值 的过渡阶段),移除leave动画

  • 2020-12-01 16:21:47

    Meteor与express结合开发

    Meteor本质上是一个已经公开了连接 http服务器的节点应用程序,这意味着您可以像下面这样定义服务器路由:,如果您坚持使用Express,则可以将Express路由注册为Connect中间件,如下所示:

  • 2020-12-01 16:25:32

    nuxtjs引入jquery

    nuxt引入jQuery库 nuxtjs如何添加 Webpack 插件?