maven私服nexus上传第三方jar包以及下载

在maven中,配置setting.xml,之后通过mvn deploy命令可以将包传入私服

有些第三方jar包,我们需要一般通过新建仓库进行上传

setting.xml配置

复制代码
<servers>
    <server>
      <id>nexus</id>
      <username>gaming</username>
      <password>gaming</password>
    </server>
</servers>

通过cmd窗口手工在后台上传

mvn deploy:deploy-file -DgroupId=net.sf -DartifactId=json-lib -Dversion=2.4 -Dpackaging=jar 
-Dfile=E:/json-lib-2.4.jar -Durl=http://192.168.1.222/nexus/repository/releases/ -DrepositoryId=releases

参数说明

mvn deploy:deploy-file

  • -DgroupId=xxxxxx 就相当于pom中的groupId
  • -DartifactId=xxxxxx 就相当于pom中的artifactId
  • -Dversion=xxxxxx 就相当于pom中的版本号version
  • -Dpackaging=xxxxxx 就相当于pom中打包方式
  • -Dfile=xxxxxx 本地环境
  • -Durl=xxxxxx 上传的url
  • -DrepositoryId=xxxxxx 对应的是setting.xml 里边的id

下载,需要修改maven的setting.xml

设置repository

 之后reimport即可。

原文地址:https://www.cnblogs.com/wang3680/p/12081961.html