【发布时间】:2017-05-19 11:43:46
【问题描述】:
我已使用 pom 将 zip 文件上传到本地 nexus 存储库。它似乎已正确上传。然后我尝试使用以下方式将其下载到另一个项目中:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.foo</groupId>
<artifactId>projectusingofficestuff</artifactId>
<version>1.0.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependency</id>
<phase>compile</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.foo</groupId>
<artifactId>officestuff</artifactId>
<type>zip</type>
<version>1.0.0-RELEASE</version>
<overWrite>true</overWrite>
<outputDirectory>target/unpacked</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
当我尝试下载时,我得到:
[DEBUG] (s) remoteRepos = [ id: nexus
url: http://repository/nexus/repository/maven-public
layout: default
snapshots: [enabled => false, update => daily]
releases: [enabled => true, update => daily]
]
[DEBUG] (f) silent = false
[DEBUG] -- end configuration --
[INFO] Configured Artifact: com.foo:officestuff:1.0.0-RELEASE:zip
[DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://repository/nexus/repository/maven-public as mike
Downloading: http://repository/nexus/repository/maven-public/com/foo/officestuff/1.0.0-RELEASE/officestuff-1.0.0-RELEASE.zip
[DEBUG] Writing resolution tracking file /home/mike/.m2/repository/com/foo/officestuff/1.0.0-RELEASE/officestuff-1.0.0-RELEASE.zip.lastUpdated
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.763s
[INFO] Finished at: Wed Jan 04 16:13:20 EST 2017
[INFO] Final Memory: 20M/962M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.1:unpack (copy-dependency) on project projectusingofficestuff: Unable to find artifact. Could not find artifact com.foo:officestuff:zip:1.0.0-RELEASE in nexus (http://repository/nexus/repository/maven-public)
如果我直接使用以下方法搜索存储库: http://repository/nexus/repository/maven-public/com/foo/officestuff/1.0.0-RELEASE/officestuff-1.0.0-RELEASE.zip?describe
它找到工件并返回看似正确的响应。知道为什么 Maven 构建会找不到它吗?
【问题讨论】:
-
您能否尝试在您的项目目录中执行
mvn org.apache.maven.plugins:maven-dependency-plugin:3.0.0:unpack,以防万一检查旧版本是否有任何错误,或者您可能将其绑定到不正确的阶段。 -
首先我怀疑
1.0.0-RELEASE的版本是否正确。通常发布版本如下所示:1.0.0。此外,您似乎通过 pluginManagement 定义插件版本,因为您似乎使用的是非常旧版本的 maven-dependency-plugin...