搭建maven的私服nexus

1.搭建maven的私服
    http://www.sonatype.org/nexus/downloads/
    搭建私服是团队开发的基础,才能实现组内或者组间的依赖共享,要搭建私服使用工具nexus
    搭建私服启动登陆之后,发现仓库类型可以分为三大类:
        hosted:表示主机,也就是当前这台服务器可以直接访问和操作的仓库,但是其他机器可以通过配置用户的方式来访问和修改
            release:表示释放版,也就是如果你的jar包版本是release版本,将上传到该仓库中
            snapshot:保存对应的快照版本的jar包
            3th party:表示第三方的仓库
        group:表示一个群组,方便进行仓库的统一管理
    私服搭建好之后,需要在我们的开发环境中使用
        在eclipse层面进行使用
          

 <!-- 配置远程仓库,指的是我们下载依赖时,可以从该私服来进行下载 -->
            <repositories>
                <repository>
                    <id>nexus</id>
                    <name>TeamNexus Repository</name>
                    <url>http://localhost:8081/nexus/content/groups/public</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
            配置上传的远程仓库的URL
            <distributionManagement>
                <!-- 释放版的url配置 -->
                <repository>
                    <id>repository-release</id>
                    <url>http://localhost:8081/nexus/content/repositories/releases/</url>
                </repository>
                <!-- 快照版的url配置 -->
                <snapshotRepository>
                    <id>repository-snapshot</id>
                    <url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
                </snapshotRepository>
            </distributionManagement>
            配置认证账户,在maven的setting配置文件
            <server>
              <id>repository-release</id>
              <username>deployment</username>
              <password>deployment123</password>
            </server>
            <server>
              <id>repository-snapshot</id>
              <username>deployment</username>
              <password>deployment123</password>
            </server>
        在maven层面进行使用,使用更为方便
            在setting配置文件中添加关于私服的配置
            <!-- 配置私服仓库 -->
            <profile>
                <id>my-nexus</id>
                <repositories>  
                    <repository>  
                        <id>nexus</id>  
                        <name>nexus</name>  
                        <url>http://localhost:8081/nexus/content/groups/public/</url>  
                        <releases>  
                            <enabled>true</enabled>  
                        </releases>  
                        <snapshots>  
                            <enabled>true</enabled>  
                        </snapshots>  
                    </repository>  
                </repositories>
                <pluginRepositories>  
                    <pluginRepository>  
                        <id>nexus</id>  
                        <name>nexus</name>  
                        <url>http://localhost:8081/nexus/content/groups/public/</url>  
                        <releases>  
                            <enabled>true</enabled>  
                        </releases>  
                        <snapshots>  
                            <enabled>true</enabled>  
                        </snapshots>  
                    </pluginRepository>  
                </pluginRepositories>   
            </profile>
            需要激活配置
            <activeProfiles>
                <activeProfile>jdk-1.8</activeProfile>
                <activeProfile>my-nexus</activeProfile>
            </activeProfiles>
            如果需要上传jar包给私服
            <distributionManagement>
                <!-- 释放版的url配置 -->
                <repository>
                    <id>repository-release</id>
                    <url>http://localhost:8081/nexus/content/repositories/releases/</url>
                </repository>
                <!-- 快照版的url配置 -->
                <snapshotRepository>
                    <id>repository-snapshot</id>
                    <url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
                </snapshotRepository>
            </distributionManagement>


2.维护私服索引
    首先需要下载私服的索引文件:http://repo1.maven.org/maven2/.index/,下载nexus-maven-repository-index.gz和nexus-maven-repository-index.properties
    索引文件采用特殊的压缩方式,不能使用解压缩软件来解压,需要特别下载一个解压缩工具:indexer-cli-5.1.0.jar
    解压缩:java -jar indexer-cli-5.1.0.jar -u nexus-maven-repository-index.gz -d indexer
    解压完成之后,就需要配置索引文件
        (1)停止nexus服务器
        (2)覆盖索引文件,将私服的indexer下的中央仓库的索引全部删除,将解压出来的文件覆盖进去
        (3)重启nexus的服务器,索引更新完成

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

_无往而不胜_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值