Maven 錯誤: Unknown lifecycle phase ".ggstar". You must specify a valid lifecycle phase or a goal
阿新 • • 發佈:2018-12-13
一、問題描述
Windows下,需要將jar包手動匯入Maven本地倉庫,使用Power Shell執行命令:
mvn install:install-file -Dfile="E:\Tools\ipdatabase\target\ipdatabase-1.0-SNAPSHOT.jar" -DgroupId=com.ggstar -DartifactId=ipdatabase -Dversion=1.0 -Dpackaging=jar
報錯:
[ERROR] Unknown lifecycle phase ".ggstar". 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
二、問題原因
Power Shell的命令和cmd的命令有不一樣,這個命令在cmd是可以實行的。
三、解決方法
1.在cmd命令列中執行
在含pom.xml檔案的根路徑下開啟cmd命令列,然後輸入命令
mvn install:install-file -Dfile="E:\Tools\ipdatabase\target\ipdatabase-1.0-SNAPSHOT.jar" -DgroupId=com.ggstar -DartifactId=ipdatabase -Dversion=1.0 -Dpackaging=jar
然後打包成功:
[INFO] Building ipdatabase 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ ipdatabase --- [INFO] Installing E:\Tools\ipdatabase\target\ipdatabase-1.0-SNAPSHOT.jar to E:\Tools\apache-maven-3.3.9\Repository\com\ggstar\ipdatabase\1.0\ipdatabase-1.0.jar [INFO] Installing C:\Users\ADMINI~1\AppData\Local\Temp\mvninstall4727202787532518137.pom to E:\Tools\apache-maven-3.3.9\Repository\com\ggstar\ipdatabase\1.0\ipdatabase-1.0.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.703 s [INFO] Finished at: 2018-10-05T20:40:36+08:00 [INFO] Final Memory: 8M/123M [INFO] ------------------------------------------------------------------------
2.在Power Shell下
引數需要新增單引號'',如下命令即可
mvn install:install-file -Dfile="E:\Tools\ipdatabase\target\ipdatabase-1.0-SNAPSHOT.jar" '-DgroupId=com.ggstar' '-DartifactId=ipdatabase' '-Dversion=1.0' '-Dpackaging=jar'