`

Maven学习笔记(三、maven配置nexus)

阅读更多

参考:http://juvenshun.iteye.com/blog/349534

 

在maven中配置实用nexus有两种方式:

 

一、在pom.xml文件中配置,这种配置方式只会对当前工程起作用,也就是只有当前工程识别这个远程仓库,如果其他工程需要使用,则需再次配置。

 

<repositories>
       <repository>
            <id>my-repository</id>
            <name>Codehaus Snapshots</name>
            <url>http://127.0.0.1:8080/nexus/content/reponsitories/thirdparty/</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
</repositories>

  

二、在settings.xml文件中配置,这种配置方式相对于上面的方法有一劳永逸的功效,针对所有使用该maven的项目,这个远程仓库的配置都是生效。因为在settings文件中没有repositories元素,所有需要用到profile来加入该元素。

 

<settings>
<mirrors>
  <mirror>
     <!--映射到一个组里面-->
     <id>nexus</id>
     <mirrorOf>releases</mirrorOf>
     <name>remote Repositories</name>
     <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>
  </mirror>
</mirrors>
...
<profiles>
  <profile>
    <!--ID是每一个profile必备的元素-->
    <id>dev</id>
    <repositories>
      <repository>
        <id>local-nexus</id>
        <!--将组里边的仓库分别进行设置-->
        <url>http://127.0.0.1:8081/nexus/content/reponsitories/thirdparty/</url>
        <releases>
          <enabled>true</enabled>
        </releases>
        <snapshots>
          <enabled>true</enabled>
        </snapshots>
      </repository>
    </repositories>
  </profile>
</profiles>
<!--用于在build中激活所有的profiles列表-->
<activeProfiles>
  <activeProfile>dev</activeProfile>
</activeProfiles>
...
</settings>

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics