maven junit.framework不存在问题解决

转自:

http://blog.csdn.net/hongweigg/article/details/52384655



问题

在使用maven进行一个工程的编译,已加入junit包的依赖,编译的时候却总是报“junit.framework不存在”错误。

pom.xml中junit包加入如下:

[html]  view plain  copy
  1. <dependency>  
  2.     <groupId>junit</groupId>  
  3.     <artifactId>junit</artifactId>  
  4.     <version>4.12</version>  
  5.     <scope>test</scope>  
  6. </dependency>  

解决

试了N多方法,包括加入junit-dep包,依然解决不了问题,后来在加junit-dep包的时候发现,原来多了一个scope属性,将scope属性去掉后恢复正常。

[html]  view plain  copy
  1. <dependency>  
  2.     <groupId>junit</groupId>  
  3.     <artifactId>junit</artifactId>  
  4.     <version>4.12</version>  
  5. </dependency>  

原来依赖加入scope属性后,就会被约束在该生命周期内,在compile阶段不引入test阶段的依赖,也就是说编译阶段该依赖无效。

如果修改scope属性,则也可以正常运行:

[html]  view plain  copy
  1. <dependency>  
  2.     <groupId>junit</groupId>  
  3.     <artifactId>junit</artifactId>  
  4.     <version>4.12</version>  
  5.     <scope>compile</scope>  
  6. </dependency>  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值