spring中junit 提示Failed to load ApplicationContext
错误提示: 1:java.lang.IllegalStateException: Failed to load ApplicationContext
2:Error creating bean with name 'userService' defined in class path resource [UserService.xml]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
3:Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
根本原因:由于web在加载spring的配置文件(applicationContext.xml)时,发生了错误,而错误是3(cglib2不可用),所以根本原因是缺少cglib的包。
applicationContext.xml中的代理配置如下:
<!-- 指定使用cglib -->
<aop:aspectj-autoproxy proxy-target-class="true" />
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" />
</tx:attributes>
</tx:advice>
<!-- 通过AOP配置提供事务增强,让service包下所有bean的所有方法拥有事务 -->
<aop:config proxy-target-class="true">
<aop:pointcut id="serviceMethod" expression=" execution(* com.luxl.service..*(..))" />
<aop:advisor pointcut-ref="serviceMethod" advice-ref="txAdvice" />
</aop:config>
解决方法:在maven中添加cglib的包,如下:
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
</dependency>
最新文章
- RAID磁盘阵列笔记
- java生成带logo的二维码,自定义大小,logo路径取服务器端
- Oracle 数据库基础学习 (三) Oracle 四个表结构
- Weblogic监控指标
- shinydashboard包---为shiny提供BI框架
- kali linux安装virtualbox虚拟机之爬坑经历
- Windows 8.1 应用再出发 - 创建我的第一个应用
- 解决centos7重启后出现ata bus error
- matlab学习笔记 bsxfun函数
- suibi11172
- IIS 7.5站点配置
- validate中remote的用法
- MYSQL----myownstars(102)
- Atitit.hibernate体系结构大总结
- json数据相对于xml数据.
- final关键字的作用
- 性能测试工具:AB
- Bootstrap入门(二十五)JS插件2:过渡效果
- SQL Server 安装报错找不到vc_red.msi
- Android 7.1 屏幕旋转流程分析