android 循环引用,spring循环引用
在配置shiro的时候出了这么个问题:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'shiroFilter' defined in class path resource [shiro/applicationContext-shiro.xml]:
BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#5':
Cannot resolve reference to bean 'druid-stat-pointcut' while setting bean property 'pointcut';
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'druid-stat-pointcut' defined in class path resource [applicationContext.xml]:
BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor#0' defined in class path resource
[shiro/applicationContext-shiro.xml]: Cannot resolve reference to bean 'securityManager' while setting bean property 'securityManager';
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityManager'
defined in class path resource [shiro/applicationContext-shiro.xml]: Cannot resolve reference to bean 'userRealm' while setting bean property 'realm';
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRealm': I
njection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException:
Error creating bean with name 'usersServiceImpl': Bean with name 'usersServiceImpl' has been injected into other beans
[wxEchoMpMessageRouter,wxEchoMpMessageHandler,dutyDaoImpl,fileManageServiceImpl] 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.
大致的意思是,在userRealm中注入了usersService,而在userService中注入了dutyService等几个service,但是同时在这几个service中也注入了usersService,所以产生了循环注入的问题。但是这个问题在没有配置userRealm之前是没有出现过的。以上报错在最后给出了改正的提示,依据提示找到了一篇博客:
解决的办法大致是定义一个webapplicationcontext对象继承自Xmlwebapplicationcontext,将其中的AllowRawInjectionDespiteWrapping设置为true。
public class MyWebApplicationContext extends XmlWebApplicationContext {
@Override
protected DefaultListableBeanFactory createBeanFactory() {
DefaultListableBeanFactory beanFactory = super.createBeanFactory();
beanFactory.setAllowRawInjectionDespiteWrapping(true);
return beanFactory;
}
}
web.xml中添加:
contextClass
xxx.MyWebApplicationContext
问题解决,对博主的感激之情无以言表啊!
但是,这里有几个问题:
为什么在没有配置userRealm之前没有暴露这个循环引用的问题。
对于这个问题最正确的解决办法是将相关的Service解耦,但是,对于像dutyService和dutyService这样的相互调用我觉得是比较正常的,如果直接调用底层的Dao实在比较麻烦,而且会造成很多的重复代码!
笔记,完
android 循环引用,spring循环引用相关推荐
- spring循环依赖源码分析
以下讲的循环依赖时基于单例模式下的@Autowired或者set方法的spring的循环依赖 spring循环依赖 搞懂之前需要了解bean的创建过程 大概步骤如下: 1.org.springfram ...
- Spring循环依赖原理
目录 一.什么是循环依赖? 二.构造器参数循环依赖 三.单例的setter注入循环依赖 四.多例的setter注入循环依赖 五.Spring如何解决循环依赖 六.扩展 七.总结 一.什么是循环依赖? ...
- spring 源码_spring源码系列(一)——spring循环引用
众所周知spring在默认单例的情况下是支持循环引用的 为了节省图片大小我把那些可以动得gif图片做成了只循环一次,如果看到图片不动了请右键选择在新标签打开,那么图片就会动,手机用户则更简单,直接手指 ...
- spring生命周期七个过程_Spring杂文(三)Spring循环引用
众所周知spring在默认单例的情况下是支持循环引用的 Appconfig.java类的代码 @Configurable @ComponentScan("com.sadow") p ...
- Spring解决bean之间的循环依赖(循环引用)
2.概述 bean的实例化仅仅是获得了bean的实例,该bean仍在继续创建之中,之后在该bean实例的基础之上,还要做很多额外的操作,例如bean的属性填充.处理器的应用.bean的循环依赖解决等, ...
- Spring循环引用-@Async注解启动报错,而@Transactional则不会
目录 一.问题描述 二.问题分析 1.代理类 2.代理过程 三.结论 上接<Spring循环引用-@Async注解启动报错分析> 一.问题描述 Bean1Service注解@Async 启 ...
- 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 ...
- 【Java 虚拟机原理】垃圾回收算法 ( Java 虚拟机内存分区 | 垃圾回收机制 | 引用计数器算法 | 引用计数循环引用弊端 )
文章目录 一.Java 虚拟机内存分区 二.垃圾回收机制 三.引用计数器算法 ( 无法解决循环引用问题 ) 一.Java 虚拟机内存分区 Java 虚拟机内存分区 : 所有线程共有的内存区域 : 堆 ...
- IOS小知识点5之内存警告、循环引用、交叉引用
IOS的内存使用有以下几个等级,最常见的就是OSMemoryNotificationLevelWarning OSMemoryNotificationLevelUrgent typedef enum ...
最新文章
- python深浅拷贝
- Linux 操作系统原理 — Namespace 资源隔离
- javascript写各种排序算法
- 【Android 高性能音频】Oboe 音频流打开后 耳机 / 音箱 插拔事件处理 ( 设置 Oboe 音频设备 ID | setDeviceId 函数原型 | AudioStream 音频流 )
- 黎曼猜想的1/2和质子自旋的1/2会不会是一个数?
- java lambda 局部变量_java Lambda表达式访问局部变量详细介绍
- Spring Cloud构建微服务架构:消息驱动的微服务(入门)【Dalston版】
- c++ 类 A类调用B类
- python面向对象、向量化来实现神经网络和反向传播(三)
- java多线程系列:ThreadPoolExecutor源码分析
- 【翻译】Pro.Silverlight.5.in.CSharp.4th.Edition - 第三章 布局 03
- NLP产品级系统设计模式
- Python PIL(图像处理库)使用方法
- HPUX11.31环境下,更换HBA卡后的配置操作(HP-UX)
- 智能功放 ACS 保护
- 2022年6月少儿编程等级测试来了
- 曾经决心永不做游戏 但为何阿里巴巴的游戏之心一直死不了?
- AutoML 前瞻与实践 ---- AutoML 简介
- php输出绝对值,PHP实现找出有序数组中绝对值最小的数算法分析
- 简普科技Q3财报解读:业绩超过预期之后的更多确定性