目录
一、部署项目到私服
1.1 配置本地Maven
打开Maven安装目录下的 conf\settings.xml 文件(即:D:\Program Files (x86)\apache-maven-3.6.1\conf\settings.xml) 填写远程私服的认证信息,如下图所示:
1.2 配置项目pom
从远程私服的仓库列表中获取maven-public、 maven-snapshots、 maven-releases这三个仓库的URL:
maven-public URL:http://localhost:8081/repository/maven-public/
maven-snapshots URL:http://localhost:8081/repository/maven-snapshots/
maven-releases URL:http://localhost:8081/repository/maven-releases/
在createJar工程目录下的 pom.xml 文件中添加一段配置,根据工程的版本号来决定之后上传到哪个宿主仓库,如下所示:
注意: repository id必须和 上述conf\settings.xml 文件中的server id对应,否则是无法访问私服的。
<distributionManagement>
<repository>
<id>nexus</id>
<name>Releases</name>
<url>http://localhost:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus</id>
<name>Snapshot</name>
<url>http://localhost:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>