maven配置nexus实战
docker安装nexus 注意要给/data/nexus3/var/nexus-data赋777权限
docker run -id --privileged=true --name=nexus3 --restart=always -p 7001:8081 -p 7002:8082 -p 7003:8083 -v /data/nexus3/var/nexus-data:/var/nexus-data -v /data/nexus3/nexus-data/:/nexus-data/ sonatype/nexus3
maven配置nexus私服
方式一
<?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>E:\dev\repository</localRepository>
<servers>
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>123456</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>123456</password>
</server>
</servers>
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>central</mirrorOf>
<url>http://127.0.0.1:7001/repository/maven-public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>public</id>
<url>http://127.0.0.1:7001/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public</id>
<url>http://127.0.0.1:7001/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
方式二
<?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>E:\dev\repository</localRepository>
<servers>
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>123456</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>123456</password>
</server>
</servers>
<mirrors>
<mirror>
<id>mirror</id>
<mirrorOf>central,!snapshots</mirrorOf>
<url>https://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>https://maven.aliyun.com/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots</id>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<url>http://127.0.0.1:7001/repository/maven-snapshots/</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://maven.aliyun.com/nexus/content/groups/public</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>snapshots</id>
<url>http://127.0.0.1:7001/repository/maven-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
deploy 到私服仓库 pom 配置(注意:id 要和settings 文件中的server的id保持一致)
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>maven-releases</name>
<url>http://127.0.0.1:7001/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>maven-snapshots</name>
<url>http://127.0.0.1:7001/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
手动上传maven包到nexus命令(注意:DrepositoryId 对应的是server的id)
mvn deploy:deploy-file -DgroupId="com.itcast" -DartifactId="common-rpc" -Dversion="0.0.1-SNAPSHOT" -Dpackaging="jar" -Dfile="F:\jar\common-rpc-0.0.1.jar" -Durl="http://127.0.0.1:7001/repository/maven-snapshots/" -DrepositoryId="nexus-snapshots"
阿里云的私服地址
https://maven.aliyun.com/nexus/content/groups/public