linux安装nexus,并搭建私服
-
将安装包上传到/usr/local目录
-
解压
tar -zxvf nexus-3.15.2-01-unix.tar.gz
- 设置环境变量
vim /etc/profile
export MAVEN_HOME=/usr/local/nexus-3.15.2-01
export PATH=$PATH:$MAVEN_HOME/bin
source /etc/profile
- 启动
cd /usr/local/nexus-3.15.2-01/bin
nexus start
- 报错
No suitable Java Virtual Machine could be found on your system.
The version of the JVM must be 1.8.
Please define INSTALL4J_JAVA_HOME to point to a suitable JVM.
# 解决方案
cd /usr/local/nexus-3.15.2-01/bin
vi nexus
#这里填写你安装jdk对应的路径,且必须为1.8
INSTALL4J_JAVA_HOME_OVERRIDE=/usr/local/java/jdk1.8.0_212
使用docker安装
# 拉取镜像
docker pull sonatype/nexus3:3.41.0
# 启动
docker run -dit --restart=always --name nexus -p 8081:8081 sonatype/nexus3:3.41.0
# 查看控制台
docker logs -f --tail=199 68b9ce6f1400
# 服务开放8081端口
# 浏览器访问
192.xxx.xxx.xxx:8081
-
点击右上角登录
-
进入容器的指定目录查看密码
docker exec -it 68b9ce6f1400 /bin/bash
- 设置新密码
- 打开maven安装目录的settings.xml
<servers>
<server>
<id>maven-releases</id>
<username>admin</username>
<password>admin</password>
</server>
<server>
<id>maven-snapshots</id>
<username>admin</username>
<password>admin</password>
</server>
</servers>
<mirrors>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
<mirror>
<id>nexus-heima</id>
<mirrorOf>*</mirrorOf>
<url>http://196.xxx.xxx.xxx:8081/repository/maven-public/</url>
</mirror>
</mirrors>
# 将settings.xml复制到C:\Users\本机名\.m2目录下
- 在maven项目pom.xml中配置如下
<distributionManagement>
<repository>
<id>maven-release</id>
<url>http://196.xxx.xxx.xxx:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>maven-snapshots</id>
<url>http://196.xxx.xxx.xxx:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
-
发布
-
查看