环境
CPU:2核
OS:Centos6.7
MEM:4096M
搭建
下载 nexus-3.26.0-04-unix.tar.gz
安装JDK,yum install java-1.8.0-openjdk
设置系统文件句柄 /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
创建tomcat用户,使用tomcat进行后续操作
解压 nexus-3.26.0-04-unix.tar.gz(包含两个目录 sonatype-work 和 nexus-3.26.0-04),将其放入/usr/local/
启动nexus服务,/usr/local/nexus-3.26.0-04/bin/nexus run
浏览器访问 <IP>:8081
使用admin登录,初始密码在 /usr/local/sonatype-work/nexus3/admin.password,登录后修改admin密码
仓库配置
添加代理仓库
Repositories > Create repository
Name: maven-proxy
Version policy: Mixed
Layout policy: Permissive
Remote storage: http://maven.aliyun.com/nexus/content/groups/public/
将maven-proxy加入maven-public
Member repositories:
maven-releases
maven-snapshots
maven-central
maven-proxy
打包测试
配置maven setting.xml 文件
<servers>
......
<server>
<id>maven-releases</id>
<username>admin</username>
<password>******</password>
</server>
<server>
<id>maven-snapshots</id>
<username>admin</username>
<password>******</password>
</server>
......
</servers>
配置项目中的pom.xml
<distributionManagement>
<repository>
<id>maven-releases</id>
<name>maven-releases</name>
<url>http://<IP>:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>maven-snapshots</id>
<name>maven-snapshots</name>
<url>http://<IP>:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>