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>如下图是Eclipse中JUnit的版本
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.6</version>
<scope>test</scope>
</dependency>
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>