1、nexus下载地址:
https://www.sonatype.com/download-oss-sonatype
2、centos下解压下载包
tar -zxvf nexus-3.37.3-02-unix.tar.gz
3、找到 解压目录下的etc目录下nexus-default.properties文件
## DO NOT EDIT - CUSTOMIZATIONS BELONG IN $data-dir/etc/nexus.properties
##
# Jetty section
application-port=8081
application-host=0.0.0.0
nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
nexus-context-path=/nexus
# Nexus section
nexus-edition=nexus-pro-edition
nexus-features=\
nexus-pro-feature
nexus.hazelcast.discovery.isEnabled=true
4、找到bin目录下nexus.vmoptions文件
-Xms256m
-Xmx512m
-XX:MaxDirectMemorySize=512m
-XX:+UnlockDiagnosticVMOptions
-XX:+LogVMOutput
-XX:LogFile=../sonatype-work/nexus3/log/jvm.log
-XX:-OmitStackTraceInFastThrow
-Djava.net.preferIPv4Stack=true
-Dkaraf.home=.
-Dkaraf.base=.
-Dkaraf.etc=etc/karaf
-Djava.util.logging.config.file=etc/karaf/java.util.logging.properties
-Dkaraf.data=../sonatype-work/nexus3
-Dkaraf.log=../sonatype-work/nexus3/log
-Djava.io.tmpdir=../sonatype-work/nexus3/tmp
-Dkaraf.startLocalConsole=false
-Djdk.tls.ephemeralDHKeySize=2048
5、启动nexus
切换到nexus下的bin目录下 ./nexus start
6、找到nginx的nginx.conf配置nexus代理
参考官方文档配置:Run Behind a Reverse Proxy
location /nexus {
proxy_pass http://127.0.0.1:8081/nexus;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto "https";
}
重启nginx nginx -s reload -c nginx.conf
7、根据密码登录nexus
切换到 sonatype-work/nexus3 找到admin.password文件查看密码
8、登录nexus找到repository
找到maven-central 配置代理地址比如阿里云:http://maven.aliyun.com/repository/public
8、maven settings.xml文件配置
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
<server>
<id>maven-public</id>
<username>admin</username>
<password>xxxxxx</password>
</server>
<server>
<id>maven-snapshots</id>
<username>admin</username>
<password>xxxxxx</password>
</server>
<server>
<id>maven-releases</id>
<username>admin</username>
<password>xxxxxx</password>
</server>
</servers>
<mirrors>
<mirror>
<id>maven-public</id>
<name>*</name>
<url>https://xxxxxx/nexus/repository/maven-public/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>dev</id>
<repositories>
<repository>
<id>maven-public</id>
<name>Nexus Central</name>
<url>https://xxxxxx/nexus/repository/maven-public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>maven-snapshots</id>
<name>Nexus Central</name>
<url>https://xxxxxx/nexus/repository/maven-snapshots/</url>
<layout>default</layout>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>maven-public</id>
<name>Nexus Central</name>
<url>https://xxxxxx/nexus/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
</settings>
9、maven项目pom.xml文件配置 发布到nexus私服
<distributionManagement>
<repository>
<id>maven-releases</id>
<url>https://xxxxxx/nexus/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>maven-snapshots</id>
<url>https://xxxxxx/nexus/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>