nexus命令行上传jar包

    公司的nexus版本过低,安装了新的版本,需要将旧版本中部分jar包重新上传到新的nexus服务器中,由于不能全部整体迁移,考虑将需要的jar包下载下来,再批量上传到新nexus服务器中。先搭建maven环境,单独上传一个测试,再通过bat脚本,批量上传,记录过程如下。

nexus版本: 3.40.1-01

操作系统版本:Windows 10 专业版

Java版本:18.0.2.1

maven版本:3.8.6

一、首先在机器上部署Java及maven:

Java部署方法参考:Windows下安装配置JDK_xiaodaiwang的博客-CSDN博客

maven部署方法参考:Windows下Maven安装以及配置_xiaodaiwang的博客-CSDN博客

二、上传jar包

1、修改maven安装目录下的/conf/settings.xml文件,添加serve如下

 <servers>
    <server>
      <id>geowayRepo</id>
      <username>xiaodaiwang</username>
      <password>geoway123</password>
    </server>

这个账户名和密码是在nexus中创建好的用户。

2.准备命令:准备上传的包是:ns-common-2.4.1.jar

mvn deploy:deploy-file -DgroupId=xxx.xxx -DartifactId=xxx -Dversion=0.0.2 -Dpackaging=jar -Dfile=D:\xxx.jar -Durl=http://xxx.xxx.xxx.xxx:8081/repository/3rdParty/ -DrepositoryId=3rdParty

参数说明:

mvn deploy:deploy-file
-DgroupId=xxxxxx 就相当于上传的jar的groupId
-DartifactId=xxxxxx 就相当于上传的jar的artifactId
-Dversion=xxxxxx 就相当于上传的jar的版本号version
-Dpackaging=xxxxxx 就相当于pom中打包方式
-Dfile=xxxxxx 本地jar包路径 
-Durl=xxxxxx 要上传的路径url
-DrepositoryId=xxxxxx 对应的是setting.xml 里边的id

3、输入命令:

mvn deploy:deploy-file -DgroupId=com.geoway -DartifactId=ns-common -Dversion=2.4.1 -Dpackaging=jar -Dfile=C:\Users\xiaodaiwang\Downloads\ns-common-2.4.1.jar -Durl=http://atlas.geoway.com.cn:8005/nexus/repository/maven-releases/ -DrepositoryId=geowayRepo

4、nexus上查看,包已经成功上传

 

三、编写bat脚本,批量上传

猜你喜欢

转载自blog.csdn.net/xiaodaiwang/article/details/126468653