【问题标题】:Maven: unable to install 3rd party jarMaven:无法安装第 3 方 jar
【发布时间】:2011-01-22 03:41:39
【问题描述】:

尝试将第 3 方 jar 安装到我的存储库 (alfresco-repository.jar) 中。我正在使用以下命令:

mvn install:install-file -DgroupId=alfresco -DartifactId=alfresco -Dversion=3.1 -Dpackaging=jar "-Dfile=C:/Users/xxx/Development/WIP/Alfresco/common/jars/alfresco/3.1/lib/alfresco-repository-3.1.jar" -DgeneratePom=true -e

我得到以下异常(-e 用于更多信息):

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'install'.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Invalid task '.1': you must specify a valid lifecycle phase, or a goal in
 the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.BuildFailureException: Invalid task '.1': you must specify a va
lid lifecycle phase, or a goal in the format plugin:goal or pluginGroupId:plugin
ArtifactId:pluginVersion:goal
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.getMojoDescriptor
(DefaultLifecycleExecutor.java:1830)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.segmentTaskListBy
AggregationNeeds(DefaultLifecycleExecutor.java:462)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
fecycleExecutor.java:175)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:6
0)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)

        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

【问题讨论】:

  • 你确定你没有输入'mvn .1 xxxxxxxxx'吗?如果我这样做,我会得到这个确切的输出......
  • 非常确定。我直接从我的 powershell 窗口复制了上面的行。
  • 奇怪。你试过用"-Dversion=3.1"吗?
  • romaintaz,就是这样。请将其发布为答案,我会投票并给出答案...
  • @Bryce - romaintaz 建议的解决方案不一定适用于所有平台。我的回答为您的问题提供了正确的解决方案,适用于所有平台。接受吗?

标签: maven-2


【解决方案1】:

问题是您在错误的地方使用了双引号 ("),有时根本没有。您应该在所有参数值周围使用双引号。例如...

"-Dfile=C:/Users/xxx/Development/WIP/Alfresco/common/jars/alfresco/3.1/lib/alfresco-repository-3.1.jar"

...应该是...

-Dfile="C:/Users/xxx/Development/WIP/Alfresco/common/jars/alfresco/3.1/lib/alfresco-repository-3.1.jar"

...和...

-Dversion=3.1

...应该是...

-Dversion="3.1"

不同操作系统的不同命令行会不一致地处理第一个版本,但如果您只用双引号将每个参数的 value 括起来,您每次都会得到所需的行为。你的整个命令应该是这样的......

mvn install:install-file -DgroupId="alfresco" -DartifactId="alfresco" -Dversion="3.1" -Dpackaging="jar" -Dfile="C:/Users/xxx/Development/WIP/Alfresco/common/jars/alfresco/3.1/lib/alfresco-repository-3.1.jar" -DgeneratePom="true" -e

我承认并不是所有人都需要这样做,但这是一个好习惯。

【讨论】:

猜你喜欢
  • 2018-02-26
  • 2013-12-16
  • 1970-01-01
  • 2015-05-13
  • 2018-07-17
  • 1970-01-01
  • 2017-12-25
  • 1970-01-01
  • 2016-01-09
相关资源
最近更新 更多