使用Nexus搭建maven私服

1、安装nexus

进入官网 https://help.sonatype.com/repomanager2/download,根据相应的平台进行下载。

 

2、启动

2.1 windows系统

解压之后,进入\bin\jsw目录,我的是D:\Program Files\nexus\nexus-2.14.12-02-bundle\nexus-2.14.12-02\bin\jsw,然后进入相应的版本目录,我的是windows-x86-64

先安装wrapper,然后执行install-nexus进行安装,运行start-nexus进行启动。注意:均需要用管理员的权限运行。

输入http://localhost:8081/nexus/进行访问,初始账号密码是admin,admin123

 

2.2 linux系统

进入 bin目录,编辑nexus脚本,

 

vi nexus

 修改成 RUN_AS_USER=root

      nexus start

 

 

3、设置

默认的仓库如如所示:

 

hosted 宿主仓库:主要用于部署无法从公共仓库获取的构件以及自己或第三方的项目构件;

proxy 代理仓库:代理公共的远程仓库;

virtual 虚拟仓库:可以忽略,用于适配 Maven 1;

group 仓库组:Nexus 通过仓库组的概念统一管理多个仓库,这样我们在项目中直接请求仓库组即可请求到仓库组管理的多个仓库。

因此,我们在使用的时候,只用请求group类型的public的仓库即可。

 

group类型的配置:

 

 

proxy类型的配置:

 

hosted类型的配置

 

4、使用

 

可以在pom.xml文件中添加如下配置

<repositories>

    <repository>

        <id>nexus</id>

        <name>nexus</name>

        <url>http://127.0.0.1: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://127.0.0.1:8081/nexus/content/groups/public/</url>

        <releases>

            <enabled>true</enabled>

        </releases>

        <snapshots>

            <enabled>true</enabled>

        </snapshots>

    </pluginRepository>

</pluginRepositories>

 

 

<distributionManagement>

    <repository>

        <id>releases</id>

        <name>User Project Release</name>

        <url>http://127.0.0.1:8081/nexus/content/repositories/releases/</url>

    </repository>

       <snapshotRepository>

          <id>snapshots</id>

          <name>User Project SNAPSHOTS</name>

        <url>http://127.0.0.1:8081/nexus/content/repositories/snapshots/</url>

       </snapshotRepository>

</distributionManagement>

 

或者直接修改本地maven的配置文件,使得全局生效。

    <mirror>

      <id>nexus</id>

      <mirrorOf>central</mirrorOf>

      <name>internal nexus repository</name>

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

    </mirror>

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值