IDEA Maven项目上传jar包到nexus仓库图文教程
前言
确保IDEA中项目为Maven项目,并且在nexus中已经创建了Maven私服。
nexus系列博客
一、Linux 安装Nexus3.42.0-01图文教程
二、nexus创建Maven私服图文教程
三、使用nexus上传jar包图文教程
1.配置pom.xml文件
<distributionManagement>
<!--Release类型的托管资源库-->
<repository>
<!--id对应nexus仓库的id-->
<id>test_hosted</id>
<!--自定义名称-->
<name>Releases</name>
<!--仓库对应的URL地址-->
<url>http://t-test.dmsd.tech:8089/repository/test_hosted/</url>
</repository>
<!--Snapshot类型的托管资源库-->
<snapshotRepository>
<!--id对应nexus仓库的id-->
<id>test_snapshot_hosted</id>
<!--自定义名称-->
<name>Snapshot</name>
<!--仓库对应的URL地址-->
<url>http://t-test.dmsd.tech:8089/repository/test_snapshot_hosted/</url>
</snapshotRepository>
</distributionManagement>
2.配置maven的setting.xml文件
<!--nexus服务器-->
<servers>
<!--id为对应资源库id-->
<server>
<id>test_snapshot_hosted</id>
<username>admin</username>
<password>admin</password>
</server>
<server>
<id>test_hosted</id>
<username>admin</username>
<password>admin</password>
</server>
</servers>
setting 文件示例
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/SETTINGS/1.0.0">
<!-- 本地仓库地址 -->
<localRepository>F:\maven\apache-maven-3.6.1\reponsitory</localRepository>
<!--nexus服务器-->
<servers>
<!--id为对应资源库id-->
<server>
<id>test_snapshot_hosted</id>
<username>admin</username>
<password>admin</password>
</server>
<server>
<id>test_hosted</id>
<username>admin</username>
<password>admin</password>
</server>
</servers>
<!--组资源库的url地址 id和name自定义,mirrorOf的值设置为central-->
<mirrors>
<mirror>
<id>nexus</id>
<name>nexus repository</name>
<url>http://t-test.dmsd.tech:8089/repository/test_group/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
</settings>
3.执行上传
注意:由于pom.xml文件的1.0-SNAPSHOT中以SNAPSHOT为后缀,最终会上传test_snapshot_hosted资源库中
如果以RELEASE为后缀则会上传到test_hosted资源库中。
- 点击Run Maven Build
- 出现以下页面则上传成功
- 在nexus的test_snapshot_hosted(快照类型的托管资源库)查看是否上传成功
- 至此IDEA Maven项目上传jar包到nexus仓库中已经完成了。
如果博主的文章对您有所帮助,可以评论、点赞、收藏,支持一下博主!!!
本文含有隐藏内容,请 开通VIP 后查看