Skip to content

nexus

1. 下载

进入官网下载对应版本,本文以 3.4.0-02为例。

下载

2. 安装

  1. 将压缩包进行解压
sh
tar xf nexus-3.4.0-02-unix.tar.gz

解压

  1. 配置环境变量
sh
export NEXUS_HOME="安装路径" 
PATH=$PATH:$NEXUS_HOME/bin
export PATH

配置环境变量

  1. 修改配置
bash
#启动用户校验
sed -i "s/run_as_root=true/run_as_root=false/g" nexus
#启动用户
echo "run_sa_user="root"" > nexus.rc

修改配置

  1. 查看配置
bash
cat nexus-default.properties

查看配置

  1. 启动
sh
nexus start
  1. 验证是否安装成功

浏览器访问 http://IP地址:8081,输入 admin/admin123

验证是否安装成功

3. 其他

1. 配置第三方代理仓库

  1. 点击create repository

create repository

  1. 选择maven2(proxy)

配置代理

  1. 设置remote storage
bash
https://mirrors.huaweicloud.com/repository/maven/
http://mirrors.cloud.tencent.com/nexus/repository/maven-public/
https://repo1.maven.org/maven2/

设置remote storage

  1. 设置maven-public

设置maven-public

2. maven配置文件引入

修改 **maven目录**/conf/settings.xml

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">
	
  	<!-- 本地仓库目录 -->
    <localRepository>xxx</localRepository>

    <servers>
        <server>
            <id>2rd-release</id>
            <username>admin</username>
            <password>xxx</password>
        </server>

        <server>
            <id>2rd-snapshot</id>
            <username>admin</username>
            <password>xxx</password>
        </server>

    </servers>

    <mirrors>
        <mirror>
            <id>nexus</id>
            <url>http://{ip}/repository/maven-public/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
    </mirrors>

</settings>

修改项目 pom.xml文件

xml
<repositories>
	<repository>
		<id>maven-public</id>
		<url>http://112.74.41.101:8081/repository/maven-public/</url>
	</repository>
</repositories>

<distributionManagement>
		<repository>
			<id>2rd-release</id>
			<url>http://112.74.41.101:8081/repository/2rd-release/</url>
		</repository>
		<snapshotRepository>
			<id>2rd-snapshot</id>
			<url>http://112.74.41.101:8081/repository/2rd-snapshot/</url>
		</snapshotRepository>
</distributionManagement>
最近更新