AOP 注入失败的问题
启用了AOP 后,报这样的类似错误:
Error creating bean with name 'bpmpSysUserService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected com.bkc.bpmp.core.dao.BaseDao com.bkc.bpmp.core.service.BaseService.dao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bpmpSysUserMapper': Post-processing of FactoryBean's singleton object failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.sun.proxy.$Proxy24]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Cannot subclass final class class com.sun.proxy.$Proxy24
(注:个人猜测,可能不正确)
1、其他的配置都如同网上相关的AOP 一般,这里不详写了,框架采用 SpringMVC+Spring+Mybatis
2、我这里的实际情况是 没有写 接口,写了一个BaseDao,BaseService 之类的,然后直接采用继承父类来实现,然后就报 上述的错误
解决方法:这个配置写成这样 <aop:aspectj-autoproxy proxy-target-class="false"/> ,由于没有使用接口,AOP 代理采用 CGLIB, 需要在子类中都添加 默认的构造方法(理由不知)
3、我之前使用AOP 也出现过 注入失败的情况,采用一个接口、一个接口实现类,此时AOP 自动使用的代理是JDK
解决方法:接口和接口实现类 命名需要区分,且 在注入的时候采用 接口 来创建对象
AOP 注入失败的问题的更多相关文章
- SpringAOP导致@Autowired依赖注入失败
之前用springAOP做了个操作日志记录,这次在往其他类上使用的时候,service一直注入失败,找了网上好多内容,发现大家都有类似的情况出现,但是又和自己的情况不太符合.后来总结自己的情况发现:方 ...
- Spring Autowired 注入失败总是Null
报错:NullPointerException 分析:错误原因是注入失败? <context:annotation-config/> <context:component-scan ...
- 【Intellij idea】spring中@Autowired注入失败
@Autowired注入失败失败的解决办法? 现有的解决的方案是: 打开file-settings或者ctrl+alt+s -> Editor 然后在Inspections 点击搜索栏 输入Sp ...
- spring boot开发 @autowired注入失败
@autowired注入失败 会出现如下错误提示: 2018-05-28 08:39:41.857 INFO 8080 --- [ restartedMain] org.hibernate.Versi ...
- 【Spring】Service 注入失败,空指针
service层的类都有用@Service标识,但报空指针,注入失败,很可能是因为spring的application配置和springmvc的配置文件配置错误,导致容器冲突了. spring和spr ...
- Injection of autowired dependencies failed; autowire 自动注入失败,测试类已初始化过了Spring容器。
1 严重: StandardWrapper.Throwable org.springframework.beans.factory.BeanCreationException: Error creat ...
- ssm中mapper注入失败的传奇经历
最近因为要测试一个功能,需要用最短的时间来启动服务,开启测试程序,但平常所用的框架中已经集成了各种三方的东西,想着那就再重新搭建一个最简单的ssm框架吧. 搭建可参考:简单ssm最新搭建 搭建过程并不 ...
- Error creating bean with name 'unMblTotController': 注入失败
今天新来的小伙子,进公司做项目,然后自己新建了包,出了以下错误 y.UnsatisfiedDependencyException: Error creating bean with name 'unM ...
- Filter 中注入失败问题
参考: https://www.cnblogs.com/digdeep/p/4770004.html?tvd https://www.cnblogs.com/EasonJim/p/7666009.ht ...
随机推荐
- Spring JPA Junit 关闭自动回滚
因为用了JPA配合Hibernate ,采用注解默认是开启了LayzLoad也就是懒加载,所以不得不在Junit的单元测试上加上@Transactional注解 这样Spring会自动为当前线程开启S ...
- HTML 学习笔记 CSS样式(背景)
背景色 可以使用background-color属性为元素设置背景色 这个属性接受任何合法的颜色值. 可以使用background-image属性来喂元素设置背景图片. 背景重复 如果需要在页面上对背 ...
- Mysql LIMIT如何正确对其进行优化
Mysql LIMIT如何正确对其进行优化 2010-05-17 17:09 佚名 博客园 字号:T | T 我们今天主要和大家分享的是Mysql LIMIT简单介绍以及如何进行优化的相关内容的描述, ...
- centos 命令集合
链接: http://www.cnblogs.com/zitsing/archive/2012/05/02/2479009.html http://www.centoscn.com/CentOS/he ...
- 添加JSON Data到已经存在的JSON文件中
早上在学习<Post model至Web Api创建或是保存数据>http://www.cnblogs.com/insus/p/4343833.html ,如果你第二添加时,json文件得 ...
- velocity模板引擎学习(1)
velocity与freemaker.jstl并称为java web开发三大标签技术,而且velocity在codeplex上还有.net的移植版本NVelocity,(注:castle团队在gith ...
- hystrix-turbine 监控的使用
1. 概述 Demo地址:http://git.oschina.net/zhou666/spring-cloud-7simple/tree/master/cloud-hystrix-turbine ...
- Bootstrap系列 -- 4. 文本内容强调
一. 文本强调基本样式 .text-muted:提示,使用浅灰色(#999) .text-primary:主要,使用蓝色(#428bca) .text-success:成功,使用浅绿色(#3c763d ...
- [C#解惑] #1 在构造函数内调用虚方法
谜题 在C#中,用virtual关键字修饰的方法(属性.事件)称为虚方法(属性.事件),表示该方法可以由派生类重写(override).虚方法是.NET中的重要概念,可以说在某种程度上,虚方法使得多态 ...
- [BZOJ1924][Sdoi2010]所托门王的宝藏(缩点+DP)
题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1924 分析: 首先把传送门作为点建图 这个数据很弱的,没有那种卡你的. 把每行的情况存 ...