Nexus Maven Repository

本文详细介绍了如何在CentOS 6.5环境下搭建Nexus 2.14.2-01作为Maven私服,并提供了从配置到使用的全过程指南。

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

nexus 使用

nexus 搭建maven私服oss版2.14.2-01-bundle,环境为centos_x64_6.5.

下载

# wget https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.14.2-01-bundle.tar.gz 

安装

# tar -zxvf nexus-2.14.2-01-bundle.tar.gz

启动

总不是那么一帆风顺的,习惯就好

# cd nexus-2.14.2-01/bin
# ./nexus --help
Usage: ./nexus { console | start | stop | restart | status | dump }

启动nexus

#./nexus console
****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
If you insist running as root, then set the environment variable RUN_AS_USER=root before running this script.

提示要使用root启动需要先设置RUN_AS_USER=root环境变量

# export RUN_AS_USER=root
# ./nexus console

如果出现UnknownHostException

Caused by: java.net.UnknownHostException:pretent.vm.lux132: unknown error

解决方法

# vi /etc/hosts
加入一行
127.0.0.1  pretent.vm.lux132

保存再次启动ok
后台服务启动

# ./nexus start
****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
Starting Nexus OSS...
Started Nexus OSS.

看样子启动来了,在8081端口,打开浏览器输入:http://192.168.34.132:8081/nexus/(我的虚机ip),能看到搜索界面恭喜你安装成功了。
默认登陆用户名和密码为admin和admin123。

配置

bin/jsw/wrapper.conf 用来配置nexus管理程序的容器,包括jvm内存配置、日志等配置。
conif/nexus.properties用来配置管理程序端口以及相关目录等。

发布依赖到nexus

项目pom.xml

<distributionManagement>
    <repository>
        <id>user-release</id>
        <name>User Project Release</name>
        <url>http://192.168.34.132:8081/nexus/content/repositories/releases/</url>
    </repository>

    <snapshotRepository>
        <id>user-snapshots</id>
        <name>User Project SNAPSHOTS</name>
        <url>http://192.168.34.132:8081/nexus/content/repositories/snapshots/</url>
    </snapshotRepository>
</distributionManagement>

这样deploy会报401没有权限
需要配置~/.m2/setttings.xml,在servers配置

<server>
  <id>user-release</id>
  <username>deployment</username>
  <password>deployment123</password>
</server>

<server>
  <id>user-snapshots</id>
  <username>deployment</username>
  <password>deployment123</password>
</server>

这里server里的id要和pom的repository的id一致。

从nexus下载依赖

项目pom.xml需要配置仓库地址

<!-- 依赖仓库 -->
<repositories>
    <repository>
        <id>nexus</id>
        <name>nexus</name>
        <url>http://192.168.34.132:8081/nexus/content/groups/public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>
<!-- 插件 -->
<pluginRepositories>
    <pluginRepository>
        <id>nexus</id>
        <name>Team Nexus Repository</name>
        <url>http://192.168.34.132:8081/nexus/content/groups/public/</url>
    </pluginRepository>
</pluginRepositories>

这样这个项目就可以从nexus上下载依赖了,如果想让所以项目都可以使用这个nexus私服下载依赖可以配置~/.m2/setttings.xml

<profile>
  <!-- 依赖 -->
  <id>nexus</id>
  <repositories>
    <repository>
      <id>central</id>
      <name>central</name>
      <url>http://192.168.34.132:8081/nexus/content/groups/public/</url>
      <layout>default</layout>
      <releases>
            <enabled>true</enabled>
      </releases>
      <snapshots>
            <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>
  <!-- 插件 -->
  <pluginRepositories>
      <pluginRepository>
          <id>central</id>
          <url>http://192.168.34.132:8081/nexus/content/groups/public/</url>
          <releases>
                  <enabled>true</enabled>
          </releases>
          <snapshots>
                  <enabled>true</enabled>
          </snapshots>
     </pluginRepository>
  </pluginRepositories>

</profile>

<!-- activeProfiles -->
<activeProfile>nexus</activeProfile>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值