Nexus简记

安装

1
2
3
4
5
6
7
8
下载
wget https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/3/nexus-3.15.2-01-unix.tar.gz
# 解压
tar -zxvf nexus-3.15.2-01-unix.tar.gz -C ../install/
# 启动
./nexus start
# 停止
./nexus stop

反向代理

由于nexus安装在内网服务器上,外网无法访问,所以需要使用反向代理,配置如下:

内网穿透

1
ssh -C -f -N -g -R 8881:127.0.0.1:8081 root@kangyonggan.com

外网nginx的配置

1
2
3
4
5
6
7
8
9
# nexus
server {
listen 8081;
client_max_body_size 50m;
location / {
proxy_set_header Host www.kangyonggan.com:8081;
proxy_pass http://localhost:8881;
}
}

外网访问

http://kangyonggan.com:8081
admin/admin123

使用

settings.xml

1
2
3
4
5
6
7
8
9
10
11
12
<servers>
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>

pom.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
<distributionManagement>
<repository>
<id>releases</id>
<name>nexus releases</name>
<url>http://kangyonggan.com:8081/repository/maven-releases/</url>
</repository>

<snapshotRepository>
<id>snapshots</id>
<name>nexus snapshots</name>
<url>http://kangyonggan.com:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>

测试

1
mvn deploy

image.png