Maven 错误: Unknown lifecycle phase ".ggstar". You must specify a valid lifecycle phase or a goal

一、问题描述

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'

猜你喜欢

转载自blog.csdn.net/u010886217/article/details/82946884