maven编译错误? d lifecycle pha se or a goal

Unknown lifecycle phase "intall". You must specify a valid lifecycle pha
se or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-a
rtifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate,
initialize, generate-sources, process-sources, generate-resources, process-reso
urces, compile, process-classes, generate-test-sources, process-test-sources, ge
nerate-test-resources, process-test-resources, test-compile, process-test-classe
s, test, prepare-package, package, pre-integration-test, integration-test, post-
integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-sit
e, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.

一、问题描述
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'

还有不懂的可以关注私聊我,本人10年java开发经验,相信可以帮助你成为一个优秀的java程序员
温馨提示:答案为网友推荐,仅供参考
相似回答