maven私服上传和下载包
一、上传
1、在maven安装包里面的settings.xml文件里面添加如下配置:
<server>
<id>release</id>
<username>用户名</username>
<password>密码</password>
</server>
<server>
<id>snapshot</id>
<username>用户名</username>
<password>密码</password>
</server>
这里的username和password分别代表你搭建的maven私服的用户名和密码
2、在要上传的模块里面的pom.xml文件里面添加如下配置:
<distributionManagement>
<repository>
<id>release</id>
<name>Nexus Release Repository</name>
<url>http://121.4.56.246:8099/repository/hapi-host-release/</url>
</repository>
<snapshotRepository>
<id>snapshot</id>
<name>Nexus Snapshot Repository</name>
<url>http://121.4.56.246:8099/repository/hapi-host-snapshot/</url>
</snapshotRepository>
</distributionManagement>
这里的id分别对应着上面settings.xml里面server对应的id(id必须要一致),将jar上传到指定的库(hapi-host-release、hapi-host-snapshot)中
3、在idea项目中
通过deploy插件可以将jar上传到maven私服中。结果如图
二、下载
1、在maven安装包里面的settings.xml文件里面添加如下配置:
<!-- 下载jar包配置 -->
<profile>
<!--profile的id -->
<id>dev</id>
<repositories>
<repository> <!--仓库id,repositories可以配置多个仓库,保证id不重复 -->
<id>nexus</id> <!--仓库地址,即nexus仓库组的地址 -->
<url>http://121.4.56.246:8099/repository/hapi-host-release/</url> <!--是否下载releases构件 -->
<releases>
<enabled>true</enabled>
</releases> <!--是否下载snapshots构件 -->
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories> <!-- 插件仓库,maven的运行依赖插件,也需要从私服下载插件 -->
<pluginRepository> <!-- 插件仓库的id不允许重复,如果重复后边配置会覆盖前边 -->
<id>public</id>
<name>Public Repositories</name>
<url>http://121.4.56.246:8099/repository/hapi-host-release/</url>
</pluginRepository>
</pluginRepositories>
</profile>
以上配置还不算完,还必须添加以下配置进行激活
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
这里的dev代表上面profile里面的id
2、在pom.xml文件就可以添加上传的依赖