您的位置:首页 > 运维架构 > Linux

centos 安装配置 nexus maven私有仓库

2015-11-27 10:57 751 查看
nexus下载:http://www.sonatype.org/nexus/

unzip nexus-2.11.1-01-bundle.zip

cd nexus-2.11.1-01/bin/

vi nexus

#将  #RUN_AS_USER=  改为

RUN_AS_USER=root

#启动

./nexus start

#访问IP:8081/nexus

#配置开机启动

vi /etc/xinetd.d/nexus

#最后增加

/opt/nexus-2.11.1-01/bin/nexus start



vi /etc/rc.d/rc.local

#增加

/opt/nexus-2.11.1-01/bin/nexus start

访问IP:8081/nexus

1.新建两个hosted仓库myRelease和mySnapshot

2.针对以上两个仓库配置权限Privileges

3.配置角色role,

   myReleaseRole 用来发布,赋给myRelease和mySnapshot的所有权限

   mySnapshotRole 用来发布,赋给mySnapshot的所有权限,和myRelease的view和read权限

4.配置用户

配置一个开发用户 devaccount,赋予mySnapshotRole角色

配置一个部署用户 releaseaccount,赋予myReleaseRole角色

在客户端上配置maven

5.配置apache-maven-3.2.2\conf\setting.xml

在mirrors节点增加

       <mirror>

        <id>my-public</id>  

        <name>internal nexus repository</name>

        <url>http://IP:8081/nexus/content/groups/public/</url>  

        <mirrorOf>central</mirrorOf>

      </mirror>

在servers节点增加以上的两个帐号的一个

    <server>

      <id>releases-my</id>

      <username>releaseaccount</username>

      <password>111111</password>

    </server>

   

    <server>

      <id>snapshots-my</id>

      <username>devaccount</username>

      <password>111111</password>

    </server>

6.在项目的顶级pom.xml中的project节点下增加
<distributionManagement>
<snapshotRepository>
<id>snapshots-guangduo</id>
<name>Snapshots</name>
<url>http://192.168.1.34:8081/nexus/content/repositories/gd_Snapshot/</url>
</snapshotRepository>
<repository>
<id>releases-guangduo</id>
<name>Releases</name>
<url>http://192.168.1.34:8081/nexus/content/repositories/gd_Release/</url>
</repository>
</distributionManagement>

7.用命令行在项目pom.xml所在目录执行 mvn deploy

8.禁用匿名用户anonymous

/opt/nexus-2.11.1-01/bin/nexus stop

到http://repo.maven.apache.org/maven2/.index/ 下载 nexus-maven-repository-index.gz 和 nexus-maven-repository-index.properties

复制nexus-maven-repository-index.properties到sonatype-work/nexus/indexer/central-ctx

复制indexer-cli-5.1.1.jar  和 nexus-maven-repository-index.gz 到sonatype-work/nexus/indexer/

在sonatype-work/nexus/indexer/执行
java -jar indexer-cli-5.1.1.jar -u nexus-maven-repository-index.gz -d central-ctx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  cantos linux nexus maven