2012-02-13 49 views
1

我在下面简介添加到我的pom.xml:Maven中使用配置文件

<profiles> 
    <profile> 
     <id>nexus</id> 
     <activation> 
      <activeByDefault>true</activeByDefault> 
     </activation> 
     <distributionManagement> 
      <repository> 
       <id>nexusid1</id> 
        <url>http://</url> 
      </repository> 
      <snapshotRepository> 
       <id>nexusid2</id> 
       <url>http://</url> 
      </snapshotRepository> 
     </distributionManagement> 
    </profile> 
</profiles> 

我已经加入到settings.xml中:

<server> 
<id>nexusid1</id> 
<username>username</username> 
<password>passwword</password> 
    </server> 

要将项目添加到Nexus回购我用mvn deploy

在这种情况下,我需要使用配置文件吗? 如果我想部署到nexusid2这是否意味着我需要添加一个新的服务器条目到settings.xml,即使nexusid1的用户名/密码为& nexusid2是相同的?

回答

2

根据this pagemvn:deploy有一个-DaltDeploymentRepository参数。但是,恕我直言,配置文件将是更优雅的解决方案,因为您不需要记住服务器标识,而是配置文件名称。 是的,即使用户名和密码相同,您也需要将新服务器添加到settings.xml中。除了

注:Password encryption for server management

+0

谢谢,但我怎么配置它部署到nexusid2?目前它只是部署到nexusid1,因为我在settings.xml中有相应的服务器条目。我只需要添加nexusid2的服务器条目?如果是这种情况,我可以只部署到特定的服务器仓库 – 2012-02-13 15:23:14

+1

除了提到的配置文件,Afaik没有办法指定多个部署仓库。因此,您需要两个配置文件,每个服务器一个配置文件,并在settings.xml中具有匹配的条目。如果只想部署到特定服务器,最好定义这两个配置文件,但不要将其中一个用作默认配置文件,因此您可以指定要部署到的服务器配置文件。 – Corubba 2012-02-13 16:14:05