首页 > 代码库 > Maven(二)-- 搭建私服,上传jar
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。