nexus私服搭建

1.nexus 下载地址: https://www.sonatype.com/
 a)注意:
   下载时需要填写email,phone等信息
   版本: nexus-2.12.0-01-bundle.zip
2.安装nexus
 a)解压nexus并进入bin目录
 b)以管理员权限运行dos窗口,在当前路径下执行nexus.bat install
 c)执行nexus.bat start,启动nexus服务

C:\WINDOWS\system32>d:

D:\>cd D:\Profile\JAVA\nexus-2.12.0-01-bundle\nexus-2.12.0-01\bin

D:\Profile\JAVA\nexus-2.12.0-01-bundle\nexus-2.12.0-01\bin>nexus.bat start
wrapper  | The nexus service is already running with status: RUNNING
请按任意键继续. . .

D:\Profile\JAVA\nexus-2.12.0-01-bundle\nexus-2.12.0-01\bin>

3.登录
 a)使用chrome浏览器请求http://localhost:8081/nexus/,点击右上角Log in,输入账号admin,密码admin123
在这里插入图片描述
 b)nexus安装成功
4.仓库类型
 a)hosted,宿主仓库,部署自己的jar到这个类型的仓库,包括releases和snapshot两部分,Releases公司内部发布版本仓库、Snapshots公司内部测试版本仓库
​  b)proxy,代理仓库,用于代理远程的公共仓库,如maven中央仓库,用户连接私服,私服自动去中央仓库下载jar包或者插件
​  c)group,仓库组,用来合并多个hosted/proxy仓库,通常我们配置自己的maven连接仓库组
​  d)virtual(虚拟):兼容Maven1版本的jar或者插件
5.发布项目到私服(idea)
 a)配置Maven(本地仓库),修改settings.xml

<server>
    <id>releases</id>
    <username>admin</username>
    <password>admin123</password>
</server>
<server>
    <id>snapshots</id>
    <username>admin</username>
    <password>admin123</password>
</server>

.b)启动nexus服务端
 c)每次使用idea新建Maven工程都需要在pom添加私服仓库坐标

<distributionManagement>
    <repository>
        <id>releases</id>
        <url>http://localhost:8081/nexus/content/repositories/releases/</url>
    </repository>
    <snapshotRepository>
        <id>snapshots</id>
        <url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
    </snapshotRepository>
</distributionManagement>

.d)执行deploy命令,根据本项目pom.xml中version定义决定发布到哪个仓库,如果version定义为snapshot,执行 deploy后查看 nexus 的 snapshot仓库, 如果 version定义为 release则项目将发布到 nexus的 release 仓库,本项目将发布到 snapshot 仓库

<parent>
    <artifactId>nexus_learning</artifactId>
    <groupId>com.brant</groupId>
    <version>1.0-SNAPSHOT</version>
  </parent>

6.从私服下载jar包
 a)配置Maven(本地仓库),修改settings.xml

<profile>
    <id>dev</id>
    <repositories>
        <repository>
        <!--仓库 id, repositories 可以配置多个仓库,保证 id 不重复-->
        <id>nexus</id>
        <!--仓库地址,即 nexus 仓库组的地址-->
        <url>http://localhost:8081/nexus/content/groups/public/</url>
        <!--是否下载 releases 构件-->
        <releases>
            <enabled>true</enabled>
        </releases>
        <!--是否下载 snapshots 构件-->
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    </repositories>
    <pluginRepositories>
        <!-- 插件仓库, maven 的运行依赖插件,也需要从私服下载插件 -->
        <pluginRepository>
            <!-- 插件仓库的 id 不允许重复,如果重复后边配置会覆盖前边 -->
            <id>public</id>
            <name>Public Repositories</name>
            <url>http://localhost:8081/nexus/content/groups/public/</url>
        </pluginRepository>
    </pluginRepositories>
</profile>

.b)激活配置(上述的dev标签)
 c)测试
  1)注意:测试之前先删除本地仓库的jar包相关文件
  2)局域网或者本地网络都可以下载

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值