本文主要是介绍maven deploy 程序包org.junit不存在,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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] 找不到符号
[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版本支持注解版本。在工程应用中要确定自己使用的是那些版本。这篇关于maven deploy 程序包org.junit不存在的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!