楼主使用Docker + Nexus搭建Maven私有仓库,搭建私有仓库请自行百度,网上很多教程
1、上传jar包1.1上传jar需要在pom文件中添加distributionManagement,如下
4.0.0 org.example maven-project1.0-RELEASE test-releases test releases http://localhost:8881/repository/test-releases/
1.2 编写相关类
package org.wukg.demo;
public class TestUtils {
public static int testSum(int one, int two) {
return one + two;
}
}
1.3配置私服账号密码,修改maven settings.xml文件,在servers节点添加配置,注意:此处id需要和项目pom中repository id相同,这样才会使用配置的账号密码
1.4执行deploy提交jar包
我这里点击执行deploy不成功,最后用的命令行执行
命令行中在项目目录中执行 mvn deploy,看到Uploading to ...., 最后BUILD SUCCESS表示提交成功
此时登录Nexus查看仓库已经能看到刚才上传的文件
2、使用上传私服的jar包2.1 修改maven settings.xml,添加mirror,注意:此处mirrorOf配置只过滤test-releases,关于mirrorOf请自行百度
2.2 配置私服账号密码,请参考1.3
2.3添加依赖配置repository,注意:repository的id需要和settings.xml中server id相同
4.0.0 demo-serviceorg.example maven-project1.0-RELEASE test-releases test releases http://localhost:8881/repository/test-releases/
然后就可以愉快的使用了



