2013-01-08 55 views
17

如何配置maven项目以将快照和发布版本部署到Nexus?如何配置maven项目以将快照和发布版本部署到Nexus?

<distributionManagement> 
    <repository> 
     <id>InternalReleases</id> 
     <name>Internal Releases</name> 
     <url>http://192.168.16.232:8081/nexus/content/repositories/releases/</url> 
    </repository> 
    <repository> 
     <id>InternalSnapshots</id> 
     <name>Internal Snapshots</name> 
     <url>http://192.168.16.232:8081/nexus/content/repositories/snapshots/</url> 
    </repository> 
</distributionManagement> 

这种配置在Eclipse 3.8与M2E 1.2

Project build error: Non-parseable POM D:\Workspaces\W\Parent\pom.xml: Duplicated tag: 'repository' (position: START_TAG 
seen ... 

我要部署到InternalSnapshots库神器当POM版的后缀有-SNAPSHOT并部署到InternalReleases库里创建了错误,当它是RELEASE。这应该使用相同的pom.xml文件并执行相同的mvn deploy命令。

回答

28

您需要区分版本和快照存储库。 <distributionManagement>只允许一个<repository>和一个<snapshotRepository>孩子。

http://maven.apache.org/pom.html#Distribution_Management

+1

配置文件允许一个使用不同部分。如果您有多个,那么您可以使用不同的配置文件来完成它。 –

18

例pom.xml的配置

<!-- http://maven.apache.org/pom.html#Distribution_Management --> 
<distributionManagement> 
    <snapshotRepository> 
     <id>InternalSnapshots</id> 
     <name>Internal Snapshots</name> 
     <url>http://192.168.16.232:8081/nexus/content/repositories/snapshots/</url> 
    </snapshotRepository> 
    <repository> 
     <id>InternalReleases</id> 
     <name>Internal Releases</name> 
     <url>http://192.168.16.232:8081/nexus/content/repositories/releases/</url> 
    </repository> 
</distributionManagement> 

片段的.m2目录/ settings.xml中默认的Nexus安装

<server> 
    <id>thirdparty</id> 
    <username>deployment</username> 
    <password>deployment123</password> 
</server> 
<server> 
    <id>InternalReleases</id> 
    <username>deployment</username> 
    <password>deployment123</password> 
</server> 
<server> 
    <id>InternalSnapshots</id> 
    <username>deployment</username> 
    <password>deployment123</password> 
</server> 

0

你都可以做的。

添加行家释放小插件2.5.3

运行以下命令:

MVN部署清洁:发布版本:准备发布:执行

+1

这很好,但它需要Maven和项目已经配置好了,这就是问题的关键:如何配置 –