手机版
你好,游客 登录 注册
背景:
阅读新闻

Nexus配置实践

[日期:2014-06-12] 来源:Linux社区  作者:jsjwk [字体:大 中 小]

Nexus的安装以及怎样配置proxy就不讲解了,网上随便搜索就是一堆。我所在搜狐武汉研发这边暂时还没有Nexus可用,所以抽了时间我就搭建了一个。安装和搭建及其简单,但是如何配置到项目呢,尤其是有多种配置方式。

Maven 3.1.0 发布,项目构建工具 http://www.linuxidc.com/Linux/2013-07/87403.htm

Linux 安装 Maven http://www.linuxidc.com/Linux/2013-05/84489.htm

Maven3.0 配置和简单使用 http://www.linuxidc.com/Linux/2013-04/82939.htm

Ubuntu下搭建sun-jdk和Maven2 http://www.linuxidc.com/Linux/2012-12/76531.htm

Maven使用入门 http://www.linuxidc.com/Linux/2012-11/74354.htm

1.想要让maven项目能够从Nexus中取jar,其实只需要在POM中配置如下一段即可:

  <repositories> 
        <repository> 
            <snapshots> 
                <enabled>true</enabled> 
            </snapshots> 
            <id>public</id> 
          <name>Public Repositories</name> 
            <url>http://127.0.0.1:8081/nexus/content/groups/public/</url> 
        </repository> 
    </repositories> 
    <pluginRepositories> 
        <pluginRepository> 
            <id>public</id> 
            <name>Public Repositories</name> 
            <url>http://127.0.0.1:8081/nexus/content/groups/public/</url> 
        </pluginRepository> 
    </pluginRepositories>

2. 按照上述方式其实可以简单使用Nexus了,但是难道每个项目都需要这样配置一下,很麻烦,所以下面有另外一种办法,修改全局settings.xml文件,在文件里面增加如下代码:

  <profiles>
    <profile>
      <id>nexus</id>
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>false</enabled></snapshots>
        </repository>
      </repositories>
    <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>false</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
    <profile>
      <!--this profile will allow snapshots to be searched when activated-->
      <id>public-snapshots</id>
      <repositories>
        <repository>
          <id>public-snapshots</id>
          <url>http://public-snapshots</url>
          <releases><enabled>false</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
    <pluginRepositories>
        <pluginRepository>
          <id>public-snapshots</id>
          <url>http://public-snapshots</url>
          <releases><enabled>false</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
 
  <activeProfiles>
    <activeProfile>nexus</activeProfile>
    <activeProfile>public-snapshots</activeProfile>
  </activeProfiles>

这样配置完成后,就可以在任何maven项目中使用咱们的Nexus了。

更多详情见请继续阅读下一页的精彩内容: http://www.linuxidc.com/Linux/2014-06/103054p2.htm

linux
相关资讯       Nexus  Nexus配置 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款