Maven-- 搭建私服,上传jar
Posted 听歌敲代码
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Maven-- 搭建私服,上传jar相关的知识,希望对你有一定的参考价值。
一、在setting中配置 私服的镜像,在mirrors标签中加上:
<!--第一步 配置私服的镜像--> <mirror> <!--此处配置所有的构建均从私有仓库中下载 *代表所有,也可以写central --> <id>nexus</id> <mirrorOf>*</mirrorOf> <!-- url对应发私服的 Public Repositories --> <url>http://localhost:8081/nexus/content/groups/public/</url> </mirror>
二、nexus工厂的配置,在profiles标签中加上:
<profile> <id>nexus</id> <!--所有请求均通过镜像 --> <repositories> <repository> <id>central</id> <url>http://central</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <url>http://central</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </pluginRepository> </pluginRepositories> </profile>
三、激活profile配置
<!--第三步 激活profile配置 --> <activeProfiles> <!--make the profile active all the time --> <activeProfile>nexus</activeProfile> </activeProfiles>
四、在pom.xml中配置
<repositories> <repository> <id>central</id> <url>http://localhost:8081/nexus/content/groups/public/</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <url>http://localhost:8081/nexus/content/groups/public/</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </pluginRepository> </pluginRepositories>
五、配置上传到私服,在pom中:
<distributionManagement> <repository> <id>releases</id> <name>Internal Releases</name> <url>http://localhost:8081/nexus/content/repositories/releases/</url> </repository> </distributionManagement>
六、在nexus中配置权限
七、在pom.xml的servers标签中加上:
<server> <id>增加的maven库的id</id> <username>新建的名字</username> <password>pass</password> </server>
八、更新jar遇到错误:
was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced
解决办法:去自己的.m2 文件夹下把 xxx.lastUpdated 文件全部删掉,重新运行maven,ok!
以上是关于Maven-- 搭建私服,上传jar的主要内容,如果未能解决你的问题,请参考以下文章
docker搭建maven私服(nexus3),整合springboot上传下载依赖
maven上传jar包到nexus私服后的存放路径 以及 使用IDEA上传jar包的步骤