Centos Ubuntu安装nexus3

本文详细介绍如何安装配置Oracle JDK及下载部署Nexus仓库管理系统,包括环境设置、配置修改及启动过程。阐述了Nexus中各类仓库的功能,如maven-central、maven-releases等,并指导如何在Maven项目中配置settings.xml以使用Nexus仓库。

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

1 安装jdk

(注:官网要求必须是Oracle的1.8以上的jdk,不能是openjdk)

地址:https://help.sonatype.com/repomanager3/installation/java-runtime-environment

如果需要切换到Oracle的jdk可参考:https://blog.csdn.net/qq_35720307/article/details/86989781

 

2 下载nexus

下载页面:https://help.sonatype.com/repomanager3/download/download-archives---repository-manager-3

2.1 新建目录nexus后下载压缩包:

wget  http://download.sonatype.com/nexus/3/nexus-3.15.2-01-unix.tar.gz

解压:

tar -zxvf nexus-3.15.2-01-unix.tar.gz

解压会有两个文件夹:nexus的 和 sonatype-work。前者是功能的实现,后者负责存储数据

2.2 修改配置:

在目录nexus-3.15.2-01下

修改nexus用户为root: vim bin/nexus.rc      =>     run_as_user="root"

注:

可以修改默认端口:vim etc/nexus-default.properties  =>  application-port=8081

可以修改数据、日志存储位置:vim bin/nexus.vmoptions

2.3 启动:

/nexus/nexus-3.15.2-01/bin/nexus start

访问界面:http://localhost:8081

默认用户名:admin

默认密码:admin123

界面如下:

 

2.4 nexus界面

已有仓库:

maven-central:maven的中心仓库,nexus这里只是做一个代理,会从maven中心仓库下载各种jar包(不能用于上传)

可以将其Remote storage的地址换成阿里云的镜像地址:http://maven.aliyun.com/nexus/content/groups/public

 

maven-releases:   这是nexus提供的一个默认的存放我们deploy的 release版本jar包的仓库

maven-snapshots:这是nexus提供的一个默认的存放我们deploy的 snapshot版本jar包的仓库

maven-public:这是一个仓库组,访问这个仓库组的地址其实会访问组内所有仓库(center releases snapshots),我们一般配置私服的远程连接都是配置这个地址

 

也可以创建新的仓库:

proxy就是代理类,负责转发,比如之前的maven-central;

hosted就是我们常用的存放jar包的仓库,可以选择jar包的类型,release,snapshot或者mixed;

group可以包含多个仓库,比如之前的maven-public;

 

2.5 使用

maven 的 settings.xml 里增加:

<servers>
    <server>
      <id>nexus</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
  </servers>
  <mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/repository/maven-public/</url>
    </mirror>
  </mirrors>
<profiles>
  <profile>
      <id>nexus</id>
	  <properties>
        <nexus.ip>http://127.0.0.1:8081</nexus.ip>
      </properties>
  </profile>
</profiles>
  <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>

 

如果项目要deploy到私服,那pom.xml要增加:

 

 <distributionManagement>
        <repository>
            <id>nexus</id>
            <name>Releases</name>
            <url>${nexus.ip}/repository/maven-releases</url>
        </repository>
        <snapshotRepository>
            <id>nexus</id>
            <name>Snapshot</name>
            <url>${nexus.ip}/repository/maven-snapshots</url>
        </snapshotRepository>
    </distributionManagement>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值