首页 > 学院 > 开发设计 > 正文

maven deploy 程序包org.junit不存在

2019-11-06 08:39:26
字体:
来源:转载
供稿:网友

1.问题

使用eclipse向机房的私有maven仓库时,运行的命令是 clean deploy  最后失败。失败情况如下:INFO] Building user-core 0.0.1-SNAPSHOT[INFO] ------------------------------------------------------------------------[INFO][INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ user-core ---[INFO] Deleting D:/use_soft/eclipse/workspace/user-core/target[INFO][INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ user-core ---[INFO] Using 'UTF-8' encoding to copy filtered resources.[INFO] Copying 1 resource[INFO][INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ user-core ---[INFO] Changes detected - recompiling the module![INFO] Compiling 7 source files to D:/use_soft/eclipse/workspace/user-core/target/classes[INFO] -------------------------------------------------------------[ERROR] COMPILATION ERROR :[INFO] -------------------------------------------------------------[ERROR] /D:/use_soft/eclipse/workspace/user-core/src/main/java/zttc/itat/user/util/AbstractDbUnitTestCase.java:[17,17] 程序包org.junit不存在[ERROR] /D:/use_soft/eclipse/workspace/user-core/src/main/java/zttc/itat/user/util/AbstractDbUnitTestCase.java:[18,17] 程序包org.junit不存在[ERROR] /D:/use_soft/eclipse/workspace/user-core/src/main/java/zttc/itat/user/util/AbstractDbUnitTestCase.java:[19,17] 程序包org.junit不存在[ERROR] /D:/use_soft/eclipse/workspace/user-core/src/main/java/zttc/itat/user/util/EntitiesHelper.java:[3,17] 程序包org.junit不存在[ERROR] /D:/use_soft/eclipse/workspace/user-core/src/main/java/zttc/itat/user/util/AbstractDbUnitTestCase.java:[25,12] 找不到符号

2.问题原因

工程中的pom文件使用的Junit版本是3.x  工程中测试代码是用的注解形式,所以实际上工程没有引用这个pom文件指定的jar 是使用eclipse中集成的Library
<dependency>	<groupId>junit</groupId>	<artifactId>junit</artifactId>	<version>3.6</version>	<scope>test</scope></dependency> 如下图是Eclipse中JUnit的版本 

3.问题解决

3.1去掉工程的JUnit3的library,处理完如下图

3.2把工程中的pom文件的JUnit版本修改为4.x,修改完如下:
		<dependency>			<groupId>junit</groupId>			<artifactId>junit</artifactId>			<version>4.12</version>			<scope>test</scope>		</dependency>

4.问题总结

  1.JUnit 3.x版本不支持注解形式,4.x版本支持注解版本。在工程应用中要确定自己使用的是那些版本。 
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表