nexus3.x搭建私服并配置本地maven发布和依赖

本文详细介绍了如何在Ubuntu 16.04上安装配置Nexus 3.14.04版本,包括环境准备、参数调整、服务启动及使用教程。涵盖管理用户创建、仓库设置(release、snapshot、proxy)以及如何通过Maven配置使用私服。

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

1. 下载安装 nexus-3.14.04

注意:nexus-3.14.04要求安装JDK1.8以上版本

1.1 下载

下载地址:点击下载

1.2 在Linux(ubuntu-16.04.5_64bit)解压安装

# tar xf nexus-3.14.0-04-unix.tar.gz -C /usr/local/software/
# cd /usr/local/software/nexus-3.14.0-04

1.3 适当修改nexus-3.14.04参数

文件分别为nexus.rcnexus.vmoptions,笔者修改如下:

nexus.vmoptions文件:

-Xms512M
-Xmx512M
-XX:MaxDirectMemorySize=1G
-XX:+UnlockDiagnosticVMOptions
-XX:+UnsyncloadClass
-XX:+LogVMOutput
-XX:LogFile=../sonatype-work/nexus3/log/jvm.log
-XX:-OmitStackTraceInFastThrow
-Djava.net.preferIPv4Stack=true
-Dkaraf.home=.
-Dkaraf.base=.
-Dkaraf.etc=etc/karaf
-Djava.util.logging.config.file=etc/karaf/java.util.logging.properties
-Dkaraf.data=../sonatype-work/nexus3
-Djava.io.tmpdir=../sonatype-work/nexus3/tmp
-Dkaraf.startLocalConsole=false

nexus.rc文件:

run_as_user="root"

1.4 启动服务

# /usr/local/software/nexus-3.14.0-04/bin/nexus start

1.5 使用

浏览器访问http://192.168.100.167:8081,使用nexus默认用户名密码登陆admin/admin123,

1.5.1 创建管理用户

你可以配置一个管理用户:

在这里插入图片描述
创建页面:
在这里插入图片描述

1.5.2 创建仓库

登陆账号并创建自己的releasesnapshotproxy 仓库和仓库组:
在这里插入图片描述

  • 创建release仓库,选择如下图中的maven2(hosted)
    在这里插入图片描述
    创建:
    在这里插入图片描述

  • 创建snapshot仓库,选择如下图中的maven2(hosted)
    在这里插入图片描述
    创建:
    在这里插入图片描述

  • 创建proxy仓库,选择如下图中的maven2(proxy),并配置阿里云为远端仓库:http://maven.aliyun.com/nexus/content/groups/public
    在这里插入图片描述
    创建:
    在这里插入图片描述

  • 创建仓库组用户使用者在mavensettings.xml中配置使用
    在这里插入图片描述
    创建:
    在这里插入图片描述

2. 使用nexus私服

2.1 配置本地Maven settings.xml

<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

  <servers>
    <server>
      <id>releases</id>
      <username>jerry</username>
      <password>123456</password>
    </server>
    <server>
      <id>snapshots</id>
      <username>jerry</username>
      <password>123456</password>
    </server>
  </servers>
  <mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>central</mirrorOf>
      <name>*</name>
      <url>http://192.168.100.167:8081/repository/java-public/</url>
    </mirror>
  </mirrors>
</settings>

2.2 配置项目pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.zjw</groupId>
  <artifactId>my-util</artifactId>
  <version>2.1-SNAPSHOT</version>
  <distributionManagement>
    <repository>
      <id>releases</id>
      <url>http://192.168.100.167:8081/repository/java-release/</url>
    </repository>
    <snapshotRepository>
      <id>snapshots</id>
      <url>http://192.168.100.167:8081/repository/java-snapshot/</url>
    </snapshotRepository>
  </distributionManagement>

  <dependencies>
    <dependency>
      <groupId>io.perfana</groupId>
      <artifactId>perfana-gatling-maven-plugin</artifactId>
      <version>3.0.0</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <!-- 打jar包插件 -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.0.2</version>
        <configuration>
          <excludes>
            <exclude>**/*.properties</exclude>
          </excludes>
        </configuration>
      </plugin>
      <!-- 打包源码插件 -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.0.1</version>
        <configuration>
          <attach>true</attach>
        </configuration>
        <executions>
          <execution>
            <phase>compile</phase>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值