依赖软件
JDK,Maven
下载nexus
下载: https://help.sonatype.com/repomanager3/product-information/download
解压:
tar zxvf nexus-3.38.1-01-unix.tar.gz
添加用户授权
添加用户
nexus/nexus
chown -R nexus /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64
chown -R nexus /usr/local/src/nexus/nexus
chown -R nexus /usr/local/src/nexus/sonatype-work
启动
修改nexus.vmoptions
占用内存
启动/停止
./nexus start
./nexus run
阿里云端口范围/关闭防火墙
登录/默认登录密码
http://ip:8081
默认登录账号:admin
默认密码: cd /sonatype-work/nexus3/admin.password
maven的settings文件配置和项目pom推送仓库配置
// 设置一个中心仓库或多个
<mirror>
<id>nexus</id>
<mirrorOf>central</mirrorOf> // 中央仓库的映射
<name>nexus mirror.</name>
<url>http://192.168.20.72:8080/content/groups/public</url>
</mirror>
<mirrorOf>central</mirrorOf>里是要替代的仓库的id,这里就是会代替central的。如果填*,就会替代所有仓库。
这个在pom.xml、setting.xml都可以配置,引用级别是从pom > setting
<repositories>
<repository>
<id>nexus</id>
<name>nexus</name>
<url>http://192.168.1.103:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>nexus</name>
<url>http://192.168.1.103:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<profile>
<id>Nexus</id> // 定义一个profiles
<repositories>
<repository> // 定义一个远程仓库
<id>nexus</id>
<url>http://localhost:8081/repository/maven-public/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository> // 定义一个插件仓库
<id>nexus</id>
<url>http://localhost:8081/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<!-- 激活 -->
<activeProfiles> // 激活
<activeProfile>Nexus</activeProfile>
</activeProfiles>
项目中pom配置:
<distributionManagement>
<repository>
<id>nexus-release</id>
<name>Nexus Release Repository</name>
<url>http://192.168.20.72:8080/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>Nexus Snapshots Repository</name>
<url>http://192.168.20.72:8080/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>