版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/BuFanQi_Info/article/details/81317844
下载nexus包并解压
#本文下载版本2.14.3-02 笔者可更新至3.13.0-01
# wget "https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.14.3-02-bundle.tar.gz"
# tar xfvz nexus-2.14.3-02-bundle.tar.gz
配置nexus环境变量
# cd /etc
# vi profile
i进入编辑模式,在文件最下方加入环境变量配置
export RUN_AS_USER=root
export JAVA_HOME=/usr/local/software/jdk1.8.0_161 //jdk目录
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=.:$JAVA_HOME/bin:$RUN_AS_USER:$PATH
esc退出编辑模式,shift+z+z保存退出
esc退出编辑模式,shift+z+z保存退出
修改默认端口(8081)
# cd /usr/local/software/nexus/nexus-2.14.3-02/conf
# vi nexus.properties //19行application-port=8081改为指定即可
请确保防火墙和服务器规则以开放所配置接口
启动nexus
# cd /usr/local/software/nexus/nexus-2.14.3-02/bin
# ./nexus start
nexus管理界面
访问地址:http://ip:port/nexus
本地MAVEN使用私服Nexus
对setting文件进行配置
<?xml version="1.0" encoding="UTF-8"?>
<settings 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/settings-1.0.0.xsd">
<localRepository>G:\singlecase\repository\</localRepository> <!--本地仓库 -->
<servers>
<server>
<id>sc</id>
<username>admin</username> <!--私服用户名 -->
<password>admin123</password>
</server>
</servers>
<profiles>
<profile>
<id>default</id>
<repositories>
<repository>
<id>sc</id>
<name>Public Repositories</name>
<url>http://ip:port/nexus/content/repositories/releases/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>sc</id>
<name>Public Repositories</name>
<url>http://ip:port/nexus/content/repositories/releases/</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>default</activeProfile>
</activeProfiles>
</settings>
pom文件配置
<distributionManagement>
<repository>
<id>lh</id>
<name>User Project Release</name>
<url>http://ip:port/repository/maven-releases/</url>
</repository>
</distributionManagement>
将jar上传至私服
引用私服jar
<dependency>
<groupId>xxx</groupId>
<artifactId>model</artifactId>
<version>LATEST</version>
</dependency>