目录
1.1、错误描述
今天在工作中遇到了一个maven install打包报错的问题,报错提示大概是说有测试失败的内容,所有报错内容如下所示:
There are test failures.
Please refer to E:\xxxx\yyyy\zzz-common\target\surefire-reports for the individual test results.
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
看了网上的一些解决方案,都说是添加【maven-surefire-plugin】插件,配置【】属性为true,表示跳过测试阶段,重新reload一下maven项目,再次install打包尝试,发现我的工程还是报错。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</build>
接着我想了一下,既然是maven测试阶段报错,那我要是没有测试文件不就行了吗?于是,我就把【src/test/java】包下的代码给删掉了,再次进行install操作,哎,这一次就可以成功install打包啦!!!
其实还有另外一个解决办法,如下所示。
1.2、解决方案
还有一种解决办法就是,在IDEA中的maven管理界面,勾选【Toggle Skip Tests Mode】,设置maven打包时候跳过测试阶段,如下图所示:
这种方式更加快捷方便,不需要修改任务的代码,到此,maven install报错的问题就解决啦。