(异常)Circular reference involving containing bean
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相关推荐
- 解决Circular reference问题
错误代码: package com.imooc.miaosha.redis;import com.alibaba.fastjson.JSON; import org.springframework.b ...
- 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 ...
- Requested bean is currently in creation: Is there an unresolvable circular reference?
2019独角兽企业重金招聘Python工程师标准>>> 今天开发写代码,运行代码的时候 出现了 这个错误 : Requested bean is currently in creat ...
- Spring aop 循环依赖 Is there an unresolvable circular reference?
问题描述 在使用Spring通过注解方式实现AOP时报出循环依赖错误 完整的报错信息: Caused by: org.springframework.beans.factory.BeanCurrent ...
- illegal cyclic reference involving object InterfaceAudience
最近开发Spark应用程序,用到了scala反射,但是却一直报错循环引用 InterfaceAudience,感觉很奇怪,后来排查错因才发现,原来FileSystem类不可以作为反射的方法的参数,一旦 ...
- 成功解决成功解决return _iterencode(o, 0) ValueError: Circular reference detected
成功解决成功解决return _iterencode(o, 0) ValueError: Circular reference detected 目录 解决问题 解决思路 解决方法 解决问题 retu ...
- 怎么解决web service circular reference 问题
下面是一个非常简单的例子: using System; using System.Data; using System.Configuration; using System.Web; using S ...
- Activti整合SSM的异常(DbSqlSession或者Error creating bean with name 'processEngine)
Activti整合SSM的异常(DbSqlSession或者Error creating bean with name 'processEngine) 我在使用activiti整合ssm时,刚开始的时 ...
- @Autowire注入了bean(A)在当前类,但其他类需要调用这个A,报null异常,使用get获取bean为解决方案
@Autowire注入了bean(A)在当前类,但其他类需要调用这个A,报null异常,使用get获取bean为解决方案 问题背景 解决方案 心得 Lyric: 远远抛开一切 问题背景 在做项目时,我 ...
最新文章
- 热点话题:全面解析有关网上邻居的内幕
- java url使用rest风格_Restful风格的URL请求
- 大数据笔记2019.5.6
- php 命名空间 create_function,PHP create_function()注入命令执行漏洞
- boost::graph模块实现双连通分量算法的测试程序
- Zend Studio使用
- Android软键盘与EditText近乎完美的交互
- 用 Nginx 禁止国外 IP 访问我的网站..
- 属牛的女宝宝取名:聪明上进、清秀纯真的女孩名字
- Java中sqrt的抬头,Java Math.sqrt()方法
- java计算机毕业设计企业员工考勤系统的设计与实现源代码+数据库+系统+lw文档
- 在线绘制函数图像和在线图标绘制网址
- [有人@你] BIM建模助手顺手搞了个活动
- 高项_第十二章项目采购管理
- 写代码写到70岁,是一种什么样的体验?
- 实验六 文本串的加密解密
- arcgis的python安装包_用Python使用arcgis中站点包arcpy
- 2018中国财经文学论坛在杭圆满举行
- vue中怎么把图片转换成base64字符串 , 以及base64字符串怎么转换成图片路径
- HTTP 状态消息 200 302 304 403 404 500 分别表示什么?