2010-03-18 114 views
3

試圖安裝第三方jar到我的倉庫(alfresco-repository.jar)。我使用下面的命令:Maven:無法安裝第三方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) 
+0

你確定你沒有輸入'mvn .1 xxxxxxxxx'?我得到這個確切的輸出,如果我做... – 2010-03-18 14:47:03

+0

很確定。我直接從PowerShell窗口複製上面的代碼行。 – 2010-03-18 14:50:54

+2

奇怪。你是否嘗試使用'「-Dversion = 3.1」? – romaintaz 2010-03-18 15:13:39

回答

4

的問題是,你正在使用雙引號(」 )在錯誤的地方,有時甚至根本沒有。你應該使用周圍所有的參數值的雙引號。比如......

"-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" 
不同的操作系統將處理的第一個版本不一致,但如果你的

不同的命令行只使用雙引號括起每個參數的,每次都會得到所需的行爲。你的整個命令應該看起來像這樣...

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 

我承認這不是必要的,但它是一個好習慣。

+0

這個答案應該被接受 - 謝謝! – 2011-09-23 13:32:17

+0

接受並標記 - 謝謝! – 2011-09-28 19:55:45

+1

一歲多,幫了我很多!謝謝 :) – 2012-12-05 09:05:55