簡體   English   中英

我在使用 Maven 時遇到問題

[英]I'm having issues with Maven

我最近才開始學習 Java,並且正在嘗試使用 Maven 進行我的第一個項目(以前從未使用過)。 但是,我似乎無法讓 Maven 正常工作。

我正在運行 Windows 11。我下載了 Maven 並將它的 bin 添加到我系統的路徑變量中。 當我在命令行上檢查我的版本時,我得到了正確的答案,但隨后我收到一條消息,說明 cmd 如何不是有效命令。 系統路徑變量的圖片

系統路徑變量的圖片

我的項目的發行版說我應該能夠立即對項目進行測試運行。 但是,我在輸入測試后收到以下錯誤消息:

PS C:\Users\tayot\IdeaProjectmvn test -Dtest=WebCrawlerTest -DcrawlerImplementations=com.udacity.webcrawler.SequentialWebCrawler
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.udacity.webcrawler:udacity-webcrawler:jar:1.0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.110 s
[INFO] Finished at: 2022-07-11T10:52:19-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase ".udacity.webcrawler.SequentialWebCrawler". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [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/LifecyclePhaseNotFoundException
'cmd' is not recognized as an internal or external command,
operable program or batch file.
PS C:\Users\tayot\IdeaProjects\cd0381-advanced-java-programming-techniques-projectstarter-master\starter\webcrawler> mvn test -Dtest=WebCrawlerTest -DcrawlerImplementations=com.udacity.webcrawler.SequentialWebCrawler
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.udacity.webcrawler:udacity-webcrawler:jar:1.0
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. @ line 75, column 21
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO] 
[INFO] -------------< com.udacity.webcrawler:udacity-webcrawler >--------------
[INFO] Building udacity-webcrawler 1.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.112 s
[INFO] Finished at: 2022-07-11T11:05:24-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase ".udacity.webcrawler.SequentialWebCrawler". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>
:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile
, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [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/LifecyclePhaseNotFoundException
'cmd' is not recognized as an internal or external command,
operable program or batch file.
PS C:\Users\tayot\IdeaProjects\cd0381-advanced-java-programming-techniques-projectstarter-master\starter\webcrawler> mvn -e test -Dtest=WebCrawlerTest -DcrawlerImplementations=com.udacity.webcrawler.SequentialWebCrawler 
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.udacity.webcrawler:udacity-webcrawler:jar:1.0
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. @ line 75, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO] 
[INFO] -------------< com.udacity.webcrawler:udacity-webcrawler >--------------
[INFO] Building udacity-webcrawler 1.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.106 s
[INFO] Finished at: 2022-07-11T11:05:54-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase ".udacity.webcrawler.SequentialWebCrawler". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>
:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile
, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
org.apache.maven.lifecycle.LifecyclePhaseNotFoundException: Unknown lifecycle phase ".udacity.webcrawler.SequentialWebCrawler". You must specify a valid lifecycle phase or a goal in th
operable program or batch file.

我不確定問題是什么。 這是 pom.xml 文件的樣子: https ://docs.google.com/document/d/15ueL7GRSifOK0IVvC7V7ueYiL8QCMfWi0r6XtKlWeNI/edit?usp=sharing

您正在傳遞以下命令行選項:

-DcrawlerImplementations=com.udacity.webcrawler.SequentialWebCrawler

但是,錯誤消息表明它只是其中的一部分。 您可以看到com已被截斷:

Unknown lifecycle phase ".udacity.webcrawler.SequentialWebCrawler"

嘗試用雙引號括起來:

"-DcrawlerImplementations=com.udacity.webcrawler.SequentialWebCrawler"

即使問題不完整並且沒有最小的可重現示例,這里有一個在類似情況下對我有用的解決方案。

我只是將-DcrawlerImplementations參數的值包含在單引號 (') 中。

在您的情況下,請嘗試以下命令:

mvn test -Dtest=WebCrawlerTest -DcrawlerImplementations='com.udacity.webcrawler.SequentialWebCrawler'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM