Sonatype Nexus:如何在Maven的settings.xml中为多个存储库设置单个服务器凭据? [英] Sonatype Nexus: How to set a single server credentials for multiple repositories in maven's settings.xml?

查看:95
本文介绍了Sonatype Nexus:如何在Maven的settings.xml中为多个存储库设置单个服务器凭据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Nexus中有多个存储库(即发行版,快照和网站).所有3个存储库都位于公共组下,并且用户使用相同的凭据来访问所有这些存储库.在settings.xml中为每个存储库提供相同的用户名和密码,会使它们变得多余并且难以维护.

We have multiple repositories in Nexus (i.e., releases, snapshot and site). All 3 repos are under public group and users uses the same credentials to access all these repositories. Providing the same username and password in settings.xml for each repository makes it redundant and hard to maintain them.

您能否提出一种优雅的方式来描述所有3个存储库的一个服务器凭证?

Could you please suggest an elegant way to describe one server credential for all the 3 repositories?

非常感谢您的帮助.

我们正在使用maven 2.2.1和Nexus OSS 2.7.1

We are using maven 2.2.1 and Nexus OSS 2.7.1

这是我的settings.xml

<settings>    
<servers>   
<server>   
    <id>snapshot</id>   
    <username>deployment</username>   
    <password>deployment123</password>      
</server>  
<server>   
       <id>release</id>   
       <username>deployment</username>  
       <password>deployment123</password>      
</server>  
<server>  
      <id>site</id>  
      <username>deployment</username>  
      <password>deployment123</password>   
</server>  
 </servers>  
  <mirrors>  
    <mirror>  
      <!--This sends everything else to /public -->  
      <id>nexus</id>  
      <mirrorOf>*</mirrorOf>  
      <url>http://localhost:8081/nexus/content/groups/public</url>  
    </mirror>  
  </mirrors>  
  <profiles>  
    <profile>  
      <id>nexus</id>  
      <!--Enable snapshots for the built in central repo to direct -->  
      <!--all requests to nexus via the mirror -->  
      <repositories>  
        <repository>  
          <id>central</id>  
          <url>http://central</url>  
          <releases><enabled>true</enabled></releases>  
          <snapshots><enabled>true</enabled></snapshots>  
        </repository>  
      </repositories>  
      <pluginRepositories>  
        <pluginRepository>  
          <id>central</id>  
          <url>http://central</url>  
          <releases><enabled>true</enabled></releases>  
          <snapshots><enabled>true</enabled></snapshots>  
        </pluginRepository>  
       </pluginRepositories>  
 </profile>  
  </profiles>  
  <activeProfiles>  
    <!--make the profile active all the time -->  
    <activeProfile>nexus</activeProfile>  
  </activeProfiles>  
</settings>  

推荐答案

只需在setttings.xml中使用一个条目即可

Just use one entry in setttings.xml like that

<server>   
    <id>nexus</id>   
    <username>deployment</username>   
    <password>deployment123</password>      
</server>  

然后在pom.xml的distributionManagement中使用类似的内容

and then in distributionManagement in your pom.xml's you use something like that

<distributionManagement>
<repository>
  <id>nexus</id>
  <name>Nexus Releases</name>
  <url>http://localhost:8081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
  <id>nexus</id>
  <name>Nexus Snapshot</name>
  <url>http://localhost:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

要进行完全正常的设置,请查看试用指南中使用的 Nexus图书示例项目 .当然,您也可以添加具有相同ID的网站.请记住,如果id与它们只是在要查找的设置中详细说明服务器元素的标识符相同,而不是存储库的id元素,则没有问题.恕我直言,它应该称为serverId或更清楚的名称,但这就是另一回事了.

For fully working setup with this look at the Nexus Book Examples project that are used in the trial guide. You can add a site with the same id as well, of course. Keep in mind that there is no problem if the id;s are the same as they just detail the identifier of the server element in settings to look for and are NOT an id element for the repository. Imho it should be called serverId or something to be clearer, but thats a different story.

这篇关于Sonatype Nexus:如何在Maven的settings.xml中为多个存储库设置单个服务器凭据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆