1.最初的错误:
[32morg.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile[m [1m(default-testCompile)[m on project [36mHelloWorld[m: [1;31mCompilation failure[m: Compilation failure:
[[1;31mERROR[m] 不再支持源选项 5。请使用 7 或更高版本。
[[1;31mERROR[m] 不再支持目标选项 5。请使用 7 或更高版本。
[[1;31mERROR[m] -> [1m[Help 1][m
[[1;31mERROR[m]
[[1;31mERROR[m] To see the full stack trace of the errors, re-run Maven with the [1m-e[m switch.
[[1;31mERROR[m] Re-run Maven using the [1m-X[m switch to enable full debug logging.
[[1;31mERROR[m]
[[1;31mERROR[m] For more information about the errors and possible solutions, please read the following articles: [1m[Help 1][m MojoFailureException - Apache Maven - Apache Software Foundation
由于在昨天已经遇到过版本过低错误:不再支持源选项 5。请使用 7 或更高版本。
所以这次出错我在csdn搜了To see the full stack trace of the errors, re-run Maven with the [1m-e[m switch. 。认为错误在这,在试过了找到的解决办法后,还是出错。
2.
于是我又查了错误:不再支持源选项 5。请使用 7 或更高版本。
同时刚好看到一个解决办法跟昨晚的一样,但是版本却是jdk17,我昨晚修改settings.xml设置的是jdk1.8. 接着我就又改为jdk17. 结果还是报错
Results :
Failed tests: testHello(org.lanqiao.maven.HelloWorldTest): null expected:<[Hello ]lg> but was:<[hello]lg>
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;34mINFO[m] [1;31mBUILD FAILURE[m
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;34mINFO[m] Total time: 9.734 s
[[1;34mINFO[m] Finished at: 2023-02-08T21:52:46+08:00
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;31mERROR[m] Failed to execute goal [32morg.apache.maven.plugins:maven-surefire-plugin:2.12.4:test[m [1m(default-test)[m on project [36mHelloWorld[m: [1;31mThere are test failures.[m
[[1;31mERROR[m] [1;31m[m
[[1;31mERROR[m] [1;31mPlease refer to C:\Users\LG\eclipse-workspace\HelloWorld\target\surefire-reports for the individual test results.
其实这里有个非常重要的错误null expected:<[Hello ]lg> but was:<[hello]lg>,我没细看,只看了后面。 弄了半天没整好。
3.
接着我对项目先后执行了 compile、test、package、install 命令,只有compile是正常的,后面三个都惊人的出现了相同的错误:
[[1;31mERROR[m] Failed to execute goal [32morg.apache.maven.plugins:maven-surefire-plugin:2.12.4:test[m [1m(default-test)[m on project [36mHelloWorld[m: [1;31mThere are test failures.[m
[[1;31mERROR[m] [1;31m[m
[[1;31mERROR[m] [1;31mPlease refer to C:\Users\LG\eclipse-workspace\HelloWorld\target\surefire-reports for the individual test results.[m
[[1;31mERROR[m] -> [1m[Help 1][m
[[1;31mERROR[m]
[[1;31mERROR[m] To see the full stack trace of the errors, re-run Maven with the [1m-e[m switch.
我搜了Failed to 。。的内容,查到了一个博主的内容:完美解决Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:XXX:test (default-test)。。。_夜观山海的博客-CSDN博客_failed to execute goal 他提到了报错内容要具体了解的话,去哪里,我找到了那个文件,仔细看后,
发现了这句英语:junit.framework.ComparisonFailure: null expected:<Hello[ ]lg> but was:<hello[]lg>, 还好英文还行,
我去把test中的Java文件 把Hello[ ]lg 中的H改为了h ,重新执行maven test ,
它又双出错了,还是一样的报错信息,
我再次把C:\Users\LG\eclipse-workspace\HelloWorld\target\surefire-reports中的text文档看了,
发现错误变为了junit.framework.ComparisonFailure: null expected:<hello[ ]lg> but was:<hello[]lg>,,,
没错!就是差了个 空格!! 在项目的test文件夹下的java文件中,删掉空格后, maven test、package、install 都正常执行了!!
出错到写完这篇文章 花了两个多小时,,就是因为一个大小写字母和一个空格,痛苦。。。。