我目前在尝试设置一个项目以部署到内部nexus库时遇到了一个问题。由于我对Maven总体上比较陌生,所以我希望在如何设置发行版管理方面有一些我并不真正理解的东西。
基本问题是,当我执行"mvn deploy“时,工件被成功地部署到快照存储库,但Maven也尝试将其部署到发布存储库,这是失败的……这是应该的。我对我当前配置的理解是,它不应该也将其部署到发布存储库。
任何关于这方面的帮助/澄清都将令人难以置信地感激。
我的POM中有以下用于分发管理的内容:
<distributionManagement>
<repository>
<id>internal-releases</id>
<name>Internal Releases</name>
<url>http://localhost:8081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>internal-snapshots</id>
<name>Internal Snapshots</name>
<url>http://localhost:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>在POM的其他地方,我进行了以下设置,以允许使用这些存储库来获取工件:
<repositories>
<repository>
<id>internal-releases</id>
<url>http://localhost:8081/nexus/content/repositories/releases</url>
<snapshots><enabled>false</enabled></snapshots>
</repository>
<repository>
<id>internal-snapshots</id>
<url>http://localhost:8081/nexus/content/repositories/snapshots</url>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<!-- other repos, etc, etc -->
</repositories>我的settings.xml中有正确的设置,可以提供凭据,以便能够发布到在我的计算机上运行的这个测试节点实例,并且它实际上成功地部署了快照。
问题是它还会尝试将快照部署到发布存储库,该存储库被配置为不允许使用快照。
"mvn deploy“的输出包括:
[INFO] [deploy:deploy {execution: default-deploy}]
[INFO] Retrieving previous build number from internal-snapshots
Uploading: http://localhost:8081/nexus/content/repositories/snapshots/com/internal/service/1.0.0-SNAPSHOT/service-1.0.0-20101104.170338-8.war
405K uploaded (service-1.0.0-20101104.170338-8.war)
[INFO] Retrieving previous metadata from internal-snapshots
[INFO] Uploading repository metadata for: 'snapshot com.internal:service:1.0.0-SNAPSHOT'
[INFO] Retrieving previous metadata from internal-snapshots
[INFO] Uploading repository metadata for: 'artifact com.internal:service'
[INFO] Uploading project information for service 1.0.0-20101104.170338-8
[INFO] [deploy:deploy-file {execution: default}]
[INFO] Retrieving previous build number from remote-repository
[INFO] repository metadata for: 'snapshot com.internal:service:1.0.0-SNAPSHOT' could not be found on repository: remote-repository, so will be created
Uploading: http://localhost:8081/nexus/content/repositories/releases/com/internal/service/1.0.0-SNAPSHOT/service-1.0.0-20101104.170338-1.jar
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error deploying artifact: Failed to transfer file: http://localhost:8081/nexus/content/repositories/releases/com/internal/service/1.0.0-SNAPSHOT/service-1.0.0-20101104.170338-1.jar. Return code is: 400Nexus的日志包含以下内容(正如我所期望的那样):
jvm 1 | 2010-11-04 13:03:39 INFO [p-759477796-118] - o.s.n.p.m.m.M2Repos~ - Storing of item releases:/com/internal/service/1.0.0-SNAPSHOT/service-1.0.0-20101104.170338-1.jar is forbidden by Maven Repository policy. Because releases is a RELEASE repository
jvm 1 | 2010-11-04 13:03:39 ERROR [p-759477796-118] - o.s.n.r.ContentPlex~ - Got exception during processing request "PUT http://localhost:8081/nexus/content/repositories/releases/com/internal/service/1.0.0-SNAPSHOT/service-1.0.0-20101104.170338-1.jar": Storing of item releases:/com/internal/service/1.0.0-SNAPSHOT/service-1.0.0-20101104.170338-1.jar is forbidden by Maven Repository policy. Because releases is a RELEASE repository发布于 2010-11-06 10:51:40
所以最好的线索实际上就在我眼前的日志里。我之前认为的惟一工件是一个.war,但是在日志中您会注意到,Maven正试图部署到发行版中的工件实际上是一个.jar。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<packaging>jar</packaging>
<generatePom>true</generatePom>
<url>${project.distributionManagement.repository.url}</url>
<artifactId>${project.artifactId}</artifactId>
<groupId>${project.groupId}</groupId>
<version>${project.version}</version>
<file>${project.build.directory}/${project.build.finalName}.jar</file>
</configuration>
</execution>
</executions>
</plugin>请注意,这实际上是直接引用${project.distributionManagement.repository.url}。此外,这种配置有些误导,实际上应该通过war插件的attachClasses属性来完成。
发布于 2012-09-14 03:28:52
maven- ${project.distributionManagement.snapshotRepository.url}
org.apache.maven.plugins maven- deploy -plugin 2.5真部署jar真${deployFileUrl} ${project.artifactId} ${project.groupId} ${project.version}${project.build.directory}/${project.build.finalName}.jar deploy-
发布模式${project.distributionManagement.repository.url} 插件最终在maven-release-
org.apache.maven.plugins maven-release-plugin 2.0-beta-9 release-mode
发布于 2010-11-05 10:25:19
会不会是因为工件版本没有-SNAPSHOT后缀?
https://stackoverflow.com/questions/4099412
复制相似问题