一、下載軟件
1.JDK8:https://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8u211-later-5573849.html
Nexus Repository Manager需要Java 8運行時環境(JRE)。也可以到下方網盤下載。
2.Nexus開源版下載地址: https://www.sonatype.com/download-oss-sonatype
需要翻牆下載,也可以到網盤下載:https://pan.baidu.com/s/10LepsaMMaerJqPZtm-lJvQ 提取碼:mrwm
二、安裝配置
1、上傳jdk-8u221-linux-x64.tar.gz並解壓
2、vi /etc/profile
添加java環境變量
#JAVA_HOME
export JAVA_HOME=/usr/local/jdk1.8.0_221
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
保存退出 :wq
使配置生效 source /etc/profile
查看java版本 java -version
3、上傳nexus-3.19.1-01-unix.tar.gz到/usr/local/nexus/路徑下並解壓
4、cd nexus-3.19.1-01/bin路徑下,vi nexus添加環境變量
INSTALL4J_JAVA_HOME_OVERRIDE=/usr/local/jdk1.8.0_221
:wq 保存退出
5、運行nexus
在/usr/local/nexus/nexus-3.19.1-01/bin目錄下運行./nexus start或./nexus run(注:./nexus start。這種是后台啟動,./nexus run 可以看到啟動日志)
nexus的默認內存需要2G,如果本機內存較小的話會啟動失敗,提示:
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 945094656 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /tmp/hs_err_pid22397.log
此時修改/usr/local/nexus/nexus-3.19.1-01/bin/nexus.vmoptions
vi nexus.vmoptions
:wq 保存退出
修改端口號
vi /usr/local/nexus/nexus-3.19.1-01/etc/nexus-default.properties
6、訪問localhost:8081
用戶名:admin
密碼:cat /usr/local/nexus/sonatype-work/nexus3/admin.password
登錄之后會提示修改密碼
三、添加阿里雲maven代理
填寫代理庫的名稱和代理庫的url,阿里雲url:http://maven.aliyun.com/nexus/content/groups/public/
滾動到頁面最下方,點擊“Create repositoty”按鈕
重新配置maven-public組,使其包含新建的aliyun-maven。把aliyun-maven移至右側,並向上移至第一位。然后點擊保存。
四、配置maven客戶端使用私服
找到本地的中maven中的conf文件夾下的setting.xml文件