首页 > 解决方案 > 带有 mvn 测试的错误 Maven

问题描述

我是第一次使用这个工具,我无法正确构建项目。

当我尝试生命周期命令时,它通过干净的验证和编译成功构建。但是当我尝试 mvn test 时,它给了我这个错误:

[INFO] --------------------------------------------------------------------- 
---
[INFO] BUILD FAILURE
[INFO] --------------------------------------------------------------------- 
---
[INFO] Total time: 4.410 s
[INFO] Finished at: 2018-05-25T11:33:07+02:00
[INFO] --------------------------------------------------------------------- 
---
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire- 
plugin:2.20.1:test (default-test) on project gdp: Execution default-test of 
goal org.apache.maven.plugins:maven-surefire-plugin:2.20.1:test failed. 
:NullPointerException
-> [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/PluginExecutionException

mvn -v 3.5.3 我正在使用代理,我确实配置了 settings.xml 文件请帮助。谢谢你

标签: mavenbuildmaven-3maven-plugin

解决方案


通过以下方式更改 maven-surefire-plugin 的版本:

<project>
  .
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.21.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

</project>

推荐阅读