Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile

来源:互联网 发布:php 记录蜘蛛程序 编辑:程序博客网 时间:2024/06/05 11:44

1. 好坑呐,一个问题解决了好久才解决。终于可以了不容易啊。

跟着《Maven实战》学习第一个项目就出问题。Compile通过了,可是Test时有问题。网上报这个错的大部分用的都是Eclipse的。我用的Intellij IDEA。搞得好累。

(1)书上的配置时这样的:

<plugin>      <groupId>org.apache.maven.plugins</groupId>      <artifactId>maven-compiler-plugin</artifactId>      <configuration>        <source>1.5</source>        <target>1.5</target>      </configuration>    </plugin>

结果报这个错误:

[WARNING] Some problems were encountered while building the effective model for com.jasminezhao.mvntest:hello-world:jar:1.0-SNAPSHOT[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 20, column 21[WARNING] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.[WARNING] [WARNING] For this reason, future Maven versions might no longer support building such malformed projects.

需要加上:<version>3.1</version>

<plugin>                <groupId>org.apache.maven.plugins</groupId>                <artifactId>maven-compiler-plugin</artifactId>                <version>3.1</version>                <configuration>                    <source>1.5</source>                    <target>1.5</target>                </configuration>            </plugin>
(2) 报下面的错误,
[ERROR] COMPILATION ERROR :[INFO] -------------------------------------------------------------[ERROR] /D:/Maven Hello World Project/src/test/java/HelloWorldTest.java:[3,17] package org.junit does not exist[ERROR] /D:/Maven Hello World Project/src/test/java/HelloWorldTest.java:[5,24] package org.junit does not exist[ERROR] /D:/Maven Hello World Project/src/test/java/HelloWorldTest.java:[5,1] static import only from classes and interfaces[ERROR] /D:/Maven Hello World Project/src/test/java/HelloWorldTest.java:[11,6] cannot find symbol  symbol:   class Test  location: class HelloWorldTest[ERROR] /D:/Maven Hello World Project/src/test/java/HelloWorldTest.java:[17,9] cannot find symbol  symbol:   method assertEquals(java.lang.String,java.lang.String)  location: class HelloWorldTest[INFO] 5 errors[INFO] -------------------------------------------------------------[INFO] ------------------------------------------------------------------------[INFO] BUILD FAILURE[INFO] ------------------------------------------------------------------------[INFO] Total time: 9.056 s[INFO] Finished at: 2014-12-11T17:50:50+08:00[INFO] Final Memory: 11M/27M[INFO] ------------------------------------------------------------------------[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project hello-world: Compilation failure: Compilation failure:[ERROR] /D:/Maven Hello World Project/src/test/java/HelloWorldTest.java:[3,17] package org.junit does not exist[ERROR] /D:/Maven Hello World Project/src/test/java/HelloWorldTest.java:[5,24] package org.junit does not exist[ERROR] /D:/Maven Hello World Project/src/test/java/HelloWorldTest.java:[5,1] static import only from classes and interfaces[ERROR] /D:/Maven Hello World Project/src/test/java/HelloWorldTest.java:[11,6] cannot find symbol[ERROR] symbol:   class Test[ERROR] location: class HelloWorldTest[ERROR] /D:/Maven Hello World Project/src/test/java/HelloWorldTest.java:[17,9] cannot find symbol[ERROR] symbol:   method assertEquals(java.lang.String,java.lang.String)[ERROR] location: class HelloWorldTest[ERROR] -> [Help 1][ERROR][ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.[ERROR] Re-run Maven using the -X switch to enable full debug logging.[ERROR][ERROR] For more information about the errors and possible solutions, please read the following articles:[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
发现External Libraries里面有junit 4.1.0 jar,但是发现项目还是哪里有一个junit 3.8.1 jar,我估计两个jar冲突了。把两个都删了,打算重新导入。结果在项目里点击下面的按钮都不能导入,后面把.m2(C:\Users\*\.m2\repository\junit\junit)下面的包删除了。在点击旁边的一个Event Log里面蓝色字体提示的也会帮助导入包。一直不知道怎么导入maven的jar包。

截图如下:



0 0
原创粉丝点击