Question

有次开发过程中,编译器内编译成功。Maven进行打包时报错Spring进行了@Autowired关键字进行了循环依赖。报错内容如下:

2017-09-27 14:35:31,021 [main] WARN
[org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext] - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'systemConfig': Injection of autowired dependencies failed;
nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: cn.yanxml.test.service.SysDictionaryItemService cn.yanxml.test.config.SystemConfig.sysDictionaryItemService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysDictionaryItemService':
Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.yanxml.test.service.CmdbServiceService cn.yanxml.test.service.SysDictionaryItemService.cmdbServiceService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cmdbServiceService':Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.yanxml.test.service.UserService cn.yanxml.test.service.CmdbServiceService.userService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.yanxml.test.bean.Config cn.yanxml.test.service.UserService.config; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getCurrentSystemConfig' defined in class path resource [cn/yanxml/test/config/SystemConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [cn.yanxml.test.bean.Config]: Circular reference involving containing bean 'systemConfig' - consider declaring the factory method as static for independence from its containing instance. Factory method 'getCurrentSystemConfig' threw exception; nested exception is java.lang.NullPointerException
九月 27, 2017 2:35:31 下午 org.apache.catalina.core.StandardService stopInternal
信息: Stopping service Tomcat

Solution

消除循环依赖即可:

  • 去除循环依赖;
  • 如果为非复杂的逻辑关系,可以Service直接调用Dao层,而不要在Service层内进行循环调用。

(异常)Circular reference involving containing bean相关推荐

  1. 解决Circular reference问题

    错误代码: package com.imooc.miaosha.redis;import com.alibaba.fastjson.JSON; import org.springframework.b ...

  2. spring循环引用异常:in its raw version as part of a circular reference, but has eventually been wrapped

    在开发spring boot 项目时候,出现以下spring 循环引用的报错,关键在日志是: Bean with name 'deviceService' has been injected into ...

  3. Requested bean is currently in creation: Is there an unresolvable circular reference?

    2019独角兽企业重金招聘Python工程师标准>>> 今天开发写代码,运行代码的时候 出现了 这个错误 : Requested bean is currently in creat ...

  4. Spring aop 循环依赖 Is there an unresolvable circular reference?

    问题描述 在使用Spring通过注解方式实现AOP时报出循环依赖错误 完整的报错信息: Caused by: org.springframework.beans.factory.BeanCurrent ...

  5. illegal cyclic reference involving object InterfaceAudience

    最近开发Spark应用程序,用到了scala反射,但是却一直报错循环引用 InterfaceAudience,感觉很奇怪,后来排查错因才发现,原来FileSystem类不可以作为反射的方法的参数,一旦 ...

  6. 成功解决成功解决return _iterencode(o, 0) ValueError: Circular reference detected

    成功解决成功解决return _iterencode(o, 0) ValueError: Circular reference detected 目录 解决问题 解决思路 解决方法 解决问题 retu ...

  7. 怎么解决web service circular reference 问题

    下面是一个非常简单的例子: using System; using System.Data; using System.Configuration; using System.Web; using S ...

  8. Activti整合SSM的异常(DbSqlSession或者Error creating bean with name 'processEngine)

    Activti整合SSM的异常(DbSqlSession或者Error creating bean with name 'processEngine) 我在使用activiti整合ssm时,刚开始的时 ...

  9. @Autowire注入了bean(A)在当前类,但其他类需要调用这个A,报null异常,使用get获取bean为解决方案

    @Autowire注入了bean(A)在当前类,但其他类需要调用这个A,报null异常,使用get获取bean为解决方案 问题背景 解决方案 心得 Lyric: 远远抛开一切 问题背景 在做项目时,我 ...

最新文章

  1. 热点话题:全面解析有关网上邻居的内幕
  2. java url使用rest风格_Restful风格的URL请求
  3. 大数据笔记2019.5.6
  4. php 命名空间 create_function,PHP create_function()注入命令执行漏洞
  5. boost::graph模块实现双连通分量算法的测试程序
  6. Zend Studio使用
  7. Android软键盘与EditText近乎完美的交互
  8. 用 Nginx 禁止国外 IP 访问我的网站..
  9. 属牛的女宝宝取名:聪明上进、清秀纯真的女孩名字
  10. Java中sqrt的抬头,Java Math.sqrt()方法
  11. java计算机毕业设计企业员工考勤系统的设计与实现源代码+数据库+系统+lw文档
  12. 在线绘制函数图像和在线图标绘制网址
  13. [有人@你] BIM建模助手顺手搞了个活动
  14. 高项_第十二章项目采购管理
  15. 写代码写到70岁,是一种什么样的体验?
  16. 实验六 文本串的加密解密
  17. arcgis的python安装包_用Python使用arcgis中站点包arcpy
  18. 2018中国财经文学论坛在杭圆满举行
  19. vue中怎么把图片转换成base64字符串 , 以及base64字符串怎么转换成图片路径
  20. HTTP 状态消息 200 302 304 403 404 500 分别表示什么?

热门文章

  1. 企业自建应用对接企业微信发送消息接口
  2. 字符串大小写转换(全转)(大小写互转)
  3. ObjectARX 光栅图像获取
  4. 中创新航拟10月6日上市:天齐锂业与小鹏汽车为基石投资者
  5. 离婚诉讼中需要提供什么样的证据,才能证明婚后共同还贷
  6. 【TOTOLINKN150UM】TOTOLINK N150UM NANO无线网卡(150M 802.11n)【行情 报价 价格 评测】...
  7. Apple Car,能否终结特斯拉的神话?
  8. CS18M88在蓝牙人体秤上面应用
  9. oracle 面试题
  10. calabash-android 环境问题