Spring2.5.X与Junit4.5兼容性问题

问题: 项目中使用spring testcontext和junit做测试工作, 使用的时候出现如下情形:org/junit/Assume$AssumptionViolatedException; nested exception is java.lang.NoClassDefFoundError: org/junit/Assume$AssumptionViolatedException 

原因:Spring2.5的Sring-Test对于JUnit有个累人的要求,JUnit的版本必须是4.4,不支持高版本(如4.5、4.7等)。否则,会产生java.lang.ClassNotFoundException: org.junit.Assume$AssumptionViolatedException异常。  

spring的官方jira:https://jira.springsource.org/browse/SPR-5145

解决方式:
(1)你用的是Spring2.5,则必须换成junit-4.4.jar.依赖修改为:

 
 
  1. <dependency> 
  2.             <groupId>com.alibaba.external</groupId> 
  3.             <artifactId>test.junit</artifactId> 
  4.             <version>4.4</version> 
  5.             <scope>test</scope> 
  6.         </dependency> 
  7.     <dependency> 
  8.             <groupId>com.alibaba.external</groupId> 
  9.             <artifactId>sourceforge.spring.test</artifactId> 
  10.             <version>2.5.6</version> 
  11.             <scope>test</scope> 
  12.         </dependency> 


(2)将Spring升级至Spring3



本文转自 tianya23 51CTO博客,原文链接:http://blog.51cto.com/tianya23/582483,如需转载请自行联系原作者

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值