文章目录
- step1: 下载源项目到本地,确保编译无问题
- step2: maven配置文件settings.xml
- step 3: 项目的pom.xml配置要发布的仓库地址
- step 4: 执行deploy命令即可将项目打包至远程仓库
step1: 下载源项目到本地,确保编译无问题
step2: maven配置文件settings.xml
F:\software-install\apache-maven-3.6.3\conf\settings.xm
<!--1、servers添加私有仓库的id、用户名、密码-->
<servers><server><id>xxx</id><username>xxx</username><password>!@#$xxx</password></server>
</servers><!-- 2、profiles节点配置私有仓库地址并激活-->
<profiles><profile><id>xxx</id><activation><activeByDefault>true</activeByDefault><jdk>11</jdk></activation><repositories><repository><id>central</id><url>http://central</url> // 仓库地址,release版本<releases><enabled>true</enabled></releases><snapshots><updatePolicy>daily</updatePolicy><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></profiles><activeProfiles><activeProfile>xxx</activeProfile>
</activeProfiles><!--3、在maven项目里面的pom.xml配置要发布的仓库地址-->
<distributionManagement><repository><id>xx</id><name>releases</name><url>http://121.41.1xxxreleases/</url><uniqueVersion>true</uniqueVersion></repository><snapshotRepository><id>xxx</id> <name>mvn deploy</name><url>http://xxx/repository/maven-snapshots/</url></snapshotRepository>
</distributionManagement>
step 3: 项目的pom.xml配置要发布的仓库地址
<distributionManagement><repository><id>jdyDevops</id><name>releases</name><url>http://xxx/repository/maven-releases/</url><uniqueVersion>true</uniqueVersion></repository><snapshotRepository><id>jdyDevops</id><name>mvn deploy</name><url>http://xxx/repository/maven-snapshots/</url></snapshotRepository></distributionManagement>
step 4: 执行deploy命令即可将项目打包至远程仓库
idea可以在maven插件运行deploy
项目的version如果是以SNAPSHOT结尾,则项目会发布到快照仓库,否则发布到正式版本仓库
mvn deploy:deploy-file -Dmaven.test.skip=true -Dfile=D:\project\helloworld.jar -DgroupId=com.itcaset.test -DartifactId=maven-test -Dversion=1.0.0-SNAPSHOT -Dpackaging=jar -DrepositoryId=public -Durl=http://192.168.0.112/repository/roy_privrepository_snapshots/-Dmaven.test.skip=true //跳过编译、测试-Dfile=D:\project\helloworld.jar //jar包文件地址,绝对路径-DgroupId=com.itcaset.test //gruopId--pom坐标,自定义-DartifactId=maven-test //artifactId--pom坐标,自定义-Dversion //版本号-Dpackaging //打包方式-DrepositoryId //远程库服务器ID-Durl //远程库服务器地址