简体   繁体   中英

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). However, I cannot seem to get Maven to work properly.

I am running Windows 11. I downloaded Maven and added it's bin to my system's path variable. 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. 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

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:

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 (').

In your situation try something like this command below:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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