导入或打包maven项目报http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException错误,设置跳过单元测试解决

转载请标明出处:https://blog.csdn.net/men_ma/article/details/106847165.
本文出自 不怕报错 就怕不报错的小猿猿 的博客

导入或打包maven项目报http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException错误,设置跳过单元测试解决

很多时候在后台接口写完后,我们都会写对应的单元测试类去验证一下接口是否有问题的。但是很多时候在我们用在打包的时候往往会因为这些单元测试类不通过导致打包失败的。在idea如果的打包时不对单元测试类做特别处理很可能会出现一下问题:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project p4: There are test failures.
[ERROR] 
[ERROR] Please refer to E:\3.AllHomeWorkPlace\ideaProject\p4\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[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

Process finished with exit code 1

网上对这样情况的解决方式很多都是在pom.xml文件中加入:

<!--使单元测试不影响项目的编译 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
<testFailureIgnore>true</testFailureIgnore>
                </configuration>
            </plugin>

这里其实也是可以打包成功的,但是在控制台中还是会输出单元测试的错误信息。因为上面的配置是表示把单元测试的错误忽略掉。对应有强迫症的一些人来说,当然是连一点错误消息都不能出现的。这时我们可以把上面的配置修改城以下的:

 <!--使单元测试不影响项目的编译 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip><!--跳过单元测试 -->
                    <!--<testFailureIgnore>true</testFailureIgnore> --><!--这个网上很多的解决方式是这个,其实这个,其实这个配置后打包还是会编译单元测试类的,只是忽略编译单元测试类的错误. -->
                </configuration>
            </plugin>

完美解决成功:
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值