1、局域网私服

首先保证已经安装配置好了局域网的私服(具体私服的搭建可以查看相关资料)

私服页面访问地址:http://192.168.0.110:8081/nexus,使用admin登录,默认的用户名和密码是:admin/admin123

2、项目的仓库部署配置

1)pom文件中插件配置

 <build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
 <build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</build>

2)pom文件中私服仓库配置

 <distributionManagement>
<repository>
<id>thirdparty</id>
<url>http://192.168.0.110:8081/nexus/content/repositories/thirdparty/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<url>http://192.168.0.110:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
10 </distributionManagement>

Release版本和Snapshot版本对应的仓库URL,可以在私服的web页面上查看(本文的Release版本都发布到3rd party仓库下面)

View/Repositories -> Repositories -> Repositories Path

3、Maven的settings配置文件

1)配置Servers(项目pom文件中<distributionManagement>标签里面的id要与这里面的id保持一致)

 <servers>
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>thirdparty</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>

2)配置Mirror镜像,配置指向私服

 <mirrors>
<mirror>
<id>nexus</id>
<name>internal nexus repository</name>
<url>http://192.168.0.110:8081/nexus/content/groups/public/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>

3)配置仓库描述

 <profile>
<id>dev</id>
<repositories>
<repository>
<id>nexus-releases</id>
<url>http://192.168.0.110:8081/nexus/content/repositories/releases/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>nexus-snapshots</id>
<url>http://192.168.0.110:8081/nexus/content/repositories/snapshots/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>central</id>
<name>Central</name>
<url>http://192.168.0.110:8081/nexus/content/repositories/central/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>thirdparty</id>
<url>http://192.168.0.110:8081/nexus/content/repositories/thirdparty/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</profile>

4、工程项目发布

1)执行发布命令

mvn  clean  deploy

2)发布成功之后,可以在页面上查看到刚刚发布的jar包

View/Repositories -> Repositories -> 3rd party -> Browse Index

05-11 19:58
查看更多