Nexus Repository 安装及使用

本文介绍如何安装配置Nexus Repository Manager OSS 3.x版本,并与Maven结合使用来搭建本地私库。包括下载、解压、配置等步骤,以及如何在Maven的settings.xml或POM文件中进行配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Nexus Repository Manager OSS 3.x 安装

  • 下载

https://www.sonatype.com/download-oss-sonatype 选择对应的版本下载,以nexus-3.6.0-02-win64(https://www.sonatype.com/oss-thank-you-win64.zip)为例;

  • 解压

将nexus-3.6.0-02-win64.zip解压至对应目录;

  • 执行

...\nexus-3.6.0-02-win64\nexus-3.6.0-02\bin>nexus.exe /run

  • 修改配置

配置文件位于:\etc\nexus-default.properties

  1. application-port=8091 内嵌Jetty对应Web服务端口号;
  2. application-host=0.0.0.0 对应Host;
  3. nexus-context-path=/nexus
  • 注册服务(Windows Platform)

...\nexus-3.6.0-02-win64\nexus-3.6.0-02\bin>nexus.exe /install nexus

  • Nexus Repository Manager 管理页面

URL:http://localhost:8091/nexus;

162131_gG8T_1455553.png

点击右上角Sign in 按钮登录。默认用户名:admin,密码:admin123;

点击齿轮状配置按钮,进入配置页面;

162340_2vu7_1455553.png

  • Nexus、Maven结合使用,建立本地私库
  1. 修改Maven全局或者本地settings.xml;
  2. 或者直接配置在项目的POM文件中;

上述两种方式均可;

settings.xml增加如下配置:

<localRepository>D:\...\repository-dev</localRepository>

<mirror>
        <id>nexus-public</id>
        <mirrorOf>central</mirrorOf>
        <name>Nexus Repository</name>
        <url>http://<Host>:8091/nexus/repository/maven-public/</url>
    </mirror>

<server>
        <id>nexus-releases</id>
        <username>dev</username>
        <password>123456</password>
    </server>
    <server>
        <id>nexus-snapshot</id>
        <username>dev</username>
        <password>123456</password>
    </server>

POM 文件修改实例:

<repositories>
   <repository>
      <id>nexus-public</id>
      <name>nexus-public</name>
      <url>http://<Host>:8091/nexus/repository/maven-public/</url>
      <snapshots>
         <enabled>true</enabled>
      </snapshots>
      <releases>
         <enabled>true</enabled>
      </releases>
   </repository>
</repositories>

<distributionManagement>
   <repository>
      <id>nexus-nexus</id>
      <name>Releases</name>
      <url>http://<Host>:8091/nexus/repository/maven-releases/</url>
   </repository>
   <snapshotRepository>
      <id>nexus-nexus</id>
      <name>Snapshot</name>
      <url>http://<Host>:8091/nexus/repository/maven-snapshots/</url>
   </snapshotRepository>
</distributionManagement>

-------------------------------------------------------------------------------------------------------------

本地私库即可从远程仓库下载资源了:

173308_ryF9_1455553.png

转载于:https://my.oschina.net/u/1455553/blog/1559924

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值