mvn test BUILD FAILURE
具體報錯是這樣的
mvn test [22:04:05]
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.200 s
[INFO] Finished at: 2021-10-02T14:04:16Z
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/home/project). Please verify you invoked Maven from the correct directory. -> [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/MissingProjectException
解決方案如下:
This error indicates that you tried to execute a goal which requires a POM but Maven didn't find a pom.xml file in the directory you invoked it from. In most cases, fixing this is merely a matter of changing the current directory in the command prompt to point at your project's base directory. If you don't want to change the current directory, you have to tell Maven explicitly where the POM to build resides like this:
mvn -f path/to/pom.xml <goals> ...
報錯的原因是,maven 測試的位置不對,找不到pom.xml,這個錯誤表明試圖執行一個需要pom.xml的目標,但是Maven在調用它的目錄中沒有找到pom.xml文件。
在大多數情況下,解決這個問題只需在命令提示符中更改當前目錄,以指向項目的基本目錄。如果你不想改變當前目錄,你必須像這樣明確地告訴Maven要構建的POM駐留在哪里,或者也可以直接進入pom.xml所在地的目錄下進行maven測試。
總結
以上是生活随笔為你收集整理的mvn test BUILD FAILURE的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 奈奎斯特采样定理
- 下一篇: 设计模式之工厂模式和抽象工厂