简体   繁体   English

我在使用 Maven 时遇到问题

[英]I'm having issues with Maven

I just recently started learning Java and I'm trying to work on my first project with Maven (never used it before).我最近才开始学习 Java,并且正在尝试使用 Maven 进行我的第一个项目(以前从未使用过)。 However, I cannot seem to get Maven to work properly.但是,我似乎无法让 Maven 正常工作。

I am running Windows 11. I downloaded Maven and added it's bin to my system's path variable.我正在运行 Windows 11。我下载了 Maven 并将它的 bin 添加到我系统的路径变量中。 When I check which version I have on the command line, I get the correct answer, but then I get a message about how cmd is not a valid command.当我在命令行上检查我的版本时,我得到了正确的答案,但随后我收到一条消息,说明 cmd 如何不是有效命令。 Picture of System Path variable系统路径变量的图片

Picture of System Path variable系统路径变量的图片

My project's distribution says that I should be able to do a test run of the project right away.我的项目的发行版说我应该能够立即对项目进行测试运行。 However I get the following error message after entering my test:但是,我在输入测试后收到以下错误消息:

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.

I'm not sure what the issue is.我不确定问题是什么。 Here is the what the pom.xml file looks like: https://docs.google.com/document/d/15ueL7GRSifOK0IVvC7V7ueYiL8QCMfWi0r6XtKlWeNI/edit?usp=sharing这是 pom.xml 文件的样子: https ://docs.google.com/document/d/15ueL7GRSifOK0IVvC7V7ueYiL8QCMfWi0r6XtKlWeNI/edit?usp=sharing

You are passing in the following command line option:您正在传递以下命令行选项:

-DcrawlerImplementations=com.udacity.webcrawler.SequentialWebCrawler

However, the error message indicates that it's only getting part of that.但是,错误消息表明它只是其中的一部分。 You can see that the com has been truncated:您可以看到com已被截断:

Unknown lifecycle phase ".udacity.webcrawler.SequentialWebCrawler"

Try wrapping it in double quotes:尝试用双引号括起来:

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

Even though the question is incomplete and there is no minimal reproducible example, here is a solution that worked for me in a similar situation.即使问题不完整并且没有最小的可重现示例,这里有一个在类似情况下对我有用的解决方案。

I just wrapped the value of -DcrawlerImplementations parameter in single quotes (').我只是将-DcrawlerImplementations参数的值包含在单引号 (') 中。

In your situation try something like this command below:在您的情况下,请尝试以下命令:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM