2. Run Container
docker run \
--name nexus \
-p 8081:8081 \
--privileged=true \
--net network-common \
-e NEXUS_CONTEXT=nexus \
-v /elf/nexus:/nexus-data \
-itd sonatype/nexus3:3.64.0
5. Sign In
-
设置密码为nexus,禁用anonymous匿名用户访问;
-
admin - 0e5d58d6-4c75-47fd-9daf-c4375eea47ae
-
删除Anonymous User,修改admin用户邮箱:2032047511@qq.com;
-
删除用于DotNet的nuget类Repository;
-
修改maven-central仓库的Remote Storage:
https://repo1.maven.org/maven2/修改为:
https://maven.aliyun.com/repository/public
6. Server Mirror
-
admin - nexus,serverId = mirrorId;
<server>
<id>nexus-center</id>
<username>${env.NEXUS_USERNAME}</username>
<password>${env.NEXUS_PASSWORD}</password>
</server>
<mirror>
<id>nexus-center</id>
<mirrorOf>central</mirrorOf>
<url>http://192.168.0.123:8081/nexus/repository/maven-public/</url>
</mirror>
7. Pom.xml
<properties>
<nexus.base>http://192.168.0.123:8081</nexus.base>
<nexus.release>${nexus.base}/nexus/repository/maven-releases/</nexus.release>
<nexus.snapshot>${nexus.base}/nexus/repository/maven-snapshots/</nexus.snapshot>
</properties>
<distributionManagement>
<snapshotRepository>
<id>nexus-center</id>
<url>${nexus.snapshot}</url>
<uniqueVersion>false</uniqueVersion>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</snapshotRepository>
<repository>
<id>nexus-center</id>
<url>${nexus.release}</url>
<uniqueVersion>false</uniqueVersion>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</distributionManagement>
8. Settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<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">
<localRepository>D:/Install/Space/MvnRepo</localRepository>
<pluginGroups>
<pluginGroup>org.mortbay.jetty</pluginGroup>
<pluginGroup>org.sonatype.plugins</pluginGroup>
</pluginGroups>
<proxies></proxies>
<servers>
<server>
<id>nexus-center</id>
<username>${env.NEXUS_USERNAME}</username>
<password>${env.NEXUS_PASSWORD}</password>
</server>
</servers>
<mirrors>
<mirror>
<id>nexus-center</id>
<mirrorOf>central</mirrorOf>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
<!--
<url>https://maven.aliyun.com/repository/public</url>
<url>http://192.168.0.123:8081/nexus/repository/maven-public/</url>
-->
</mirrors>
<profiles>
<profile>
<id>Jdk17</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>17</jdk>
</activation>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.compilerVersion>17</maven.compiler.compilerVersion>
</properties>
</profile>
<profile>
<id>Jdk21</id>
<activation>
<activeByDefault>false</activeByDefault>
<jdk>21</jdk>
</activation>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<maven.compiler.compilerVersion>21</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>Jdk21</activeProfile>
</activeProfiles>
</settings>