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>
spring中junit 提示Failed to load ApplicationContext的更多相关文章
- spring junit 做单元测试,报 Failed to load ApplicationContext 错误
spring junit 做单元测试,报 Failed to load ApplicationContext 错误. 查找了好一会,最后发现.@ContextConfiguration(locatio ...
- 集成JUnit测试错误java.lang.IllegalStateException: Failed to load ApplicationContext
1 详细错误信息 java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.t ...
- junit测试时,出现java.lang.IllegalStateException: Failed to load ApplicationContext
课程设计要求进行junit测试,我是在已经做好的ssh项目上做的测试,测试类代码如下 package com.zhang.web.services; import static org.junit.A ...
- Junit 报错: Failed to load ApplicationContext
今天在使用Junit测试时候,报了个错误: Failed to load ApplicationContext, aspect not found;挺奇怪的 我又没有调用你,之前还好好的,现在不能使用 ...
- junit单元测试报错Failed to load ApplicationContext,但是项目发布到tomcat浏览器访问没问题
junit单元测试报错Failed to load ApplicationContext,但是项目发布到tomcat浏览器访问没问题,说明代码是没问题的,配置也没问题.开始时怀疑是我使用junit版本 ...
- SpringBoot报错:Failed to load ApplicationContext(Mapped Statements collection already contains value)
错误提示: Caused by: java.lang.IllegalArgumentException: Mapped Statements collection already contains v ...
- SpringBoot报错:Failed to load ApplicationContext( Failed to bind properties under 'logging.level')
引起条件: SpringBoot2.0下yml文件配置SLF4j日志输出日志级别 logging: level: debug 解决方法: 指定系统包路径 logging: root: debug 指定 ...
- Spring3.x 版本和 JDK1.8 不兼容导致 java.lang.IllegalStateException: Failed to load ApplicationContext
由于安装了 JDK1.8 的版本,最近在进行整合 Struts2+Spring+Hibernate 框架的时候,不小心导入了之前下载的 Spring 3.2.0 版本的 jar 包. 结果在运行测试用 ...
- SpringBoot报错:Failed to load ApplicationContext(javax.websocket.server.ServerContainer not available)
引起条件: WebSocket+单元测试,单元测试报错! 解决方法: SpringBootTest增加webEnvironment参数. https://docs.spring.io/spring-b ...
随机推荐
- [Silverlight 2.0 控制物体绕圆弧运行(C#初探篇)]
我自己写的第一个 Silverlight 2.0 程序 [Silverlight 2.0 控制物体绕圆弧运行(C#初探篇)] 程序运行时:小地球将绕着圆形轨迹做圆周运动. ...
- Oracle:手工建库
今天学习了小布老师的手工建库视频,自己也做了一遍,下面是创建过程记录: 本地环境oracle10.2.0.1 一.前期准备工作 1.设置环境变量 [oracle@app dbs]$ vi bbk.en ...
- Oracle:varchar2、nvarchar2 字段类型的区别
一直对varchar2.nvarchar2 字段类型存储字符数不清楚,现测试如下: 创建TT测试表 测试脚本如下: insert into tt values('1111','1111'); --- ...
- HDU - 1875 畅通工程再续(最小生成树)
d.c个小岛,通过建立桥,使其全部可达.求所有的桥的最小长度和. s.最小生成树,数据改成double就行了 c.Prim算法:cost[a][b]和cost[b][a]都得赋值. /* Prim算法 ...
- hdu-5120 Intersection(计算几何)
题目链接: Intersection Time Limit: 4000/4000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Ot ...
- Com组件介绍
COM组件简介 面向对象的思想难以适应这种分布式软件模型,于是组件化程序设计思想得到了迅速的发展. 按照组件化的程序设计的思想,复杂的应用程序被设计成一些小的,功能单一的组件模块,这些组件模块可以运行 ...
- printf(“%06d\n”,x);
%06d : %是格式化输入接受参数的标记 0格式化命令:结果将用零来填充 6:填充位数 d:代表十进制 数据 printf(“%06d\n”,x); console: 000001 000002 0 ...
- git stash和git stash pop(转载)
转自:http://www.cnblogs.com/highriver/archive/2012/01/05/2313808.html zz: http://blog.csdn.net/herbert ...
- SpringBoot第九篇:整合Spring Data JPA
作者:追梦1819 原文:https://www.cnblogs.com/yanfei1819/p/10910059.html 版权声明:本文为博主原创文章,转载请附上博文链接! 前言 前面几章, ...
- hdu 1171 Big Event in HDU【生成函数】
按套路列生成函数式子然后暴力乘,这样复杂度看起来非常大,但是可以动态维护最大值,这样就是O(能过)的了 仔细想想这个多项式暴力乘理解成背包dp也行? #include<iostream> ...