起因:最近因为阿里云提供了私有仓库服务,所以想停掉自己搭建的个人私服,于是涉及到了一个迁移问题。

途径是通过调用nexus自己的api来实现下载所有jar包

首先在API中获得json文件

然后开始解析文件并下载
下载代码贴图,如果仓库需要权限验证,建议先改成匿名访问。

package com.jlbtuz.tools.nexus;import com.fasterxml.jackson.databind.ObjectMapper;
import com.fire.helper.base.StringHelper;
import org.apache.commons.io.FileUtils;import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;public class DownloadJar {private static final String initPath = "D:\\nexusd\\";
//    private static final String filePath = "D:\\project-owner\\tools\\nexus-util\\src\\main\\resources\\product.json";private static final String filePath = "D:\\project-owner\\tools\\nexus-util\\src\\main\\resources\\fire.json";
//    private static final String filePath = "/close/tmp/product.json";public HashMap<String, Object> readJson() throws IOException {ObjectMapper objectMapper = new ObjectMapper();FileReader fileReader = new FileReader(filePath);BufferedReader bufferedReader = new BufferedReader(fileReader);StringBuffer sb = new StringBuffer();String s = "";while (StringHelper.isNotEmpty(s = bufferedReader.readLine())) {sb.append(s.trim());}return objectMapper.readValue(sb.toString(), HashMap.class);}public void download() throws IOException {HashMap<String, Object> stringStringHashMap = readJson();List<Map> list = (List) stringStringHashMap.get("items");for (Map map : list) {List<Map> assets = (List<Map>) map.get("assets");for (Map dMap : assets) {String url = StringHelper.valueOf(dMap.get("downloadUrl"));String path = StringHelper.valueOf(dMap.get("path"));genFile(url, initPath + path);}}}private void genFile(final String urlStr, final String path) {System.out.println(path);URL url = null;try {url = new URL(urlStr);String tempFileName = path;// 先创建文件夹File t = new File(path);t.getParentFile().mkdirs();File temp = new File(tempFileName);FileUtils.copyURLToFile(url, temp);} catch (MalformedURLException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}}public static void main(String args[]) throws IOException {new DownloadJar().download();}
}

pom文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.jlbtuz.tools</groupId><artifactId>nexus-util</artifactId><version>1.0.1</version><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target></properties><dependencies><dependency><groupId>com.jlbtuz.fire.helper</groupId><artifactId>fire-helper</artifactId><version>3.0.0</version></dependency><dependency><groupId>org.jsoup</groupId><artifactId>jsoup</artifactId><version>1.11.3</version></dependency><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId><version>2.11.3</version></dependency><!-- https://mvnrepository.com/artifact/commons-io/commons-io --><dependency><groupId>commons-io</groupId><artifactId>commons-io</artifactId><version>2.8.0</version></dependency></dependencies></project>

接下来使用阿里云工具迁移仓库就可以了
参考

$ java -jar migrate-local-repo-tool.jar -cd "/$HOME/.m2/repository/" -t "http://10.21.11.11/repository/releases/" -u admin -p admin123
参数注解:
-cd   您要迁移的本地目录-t    目标仓库地址,您可以在云效上点击仓库地址,获取您的目标仓库地址-p    密码-u    用户名

注意此处的用户名密码,需要下载setting.xml文件,在里面获取密码。

后来经过测试,可以用这个jar包迁移任意仓库目录。
这个jar包在阿里云的代码仓库里面,一下地址需要自行注册
https://repomanage.rdc.aliyun.com/my/repo

从nexus下载所有jar包方法 迁移到其他nexus中相关推荐

  1. 从网上下载的jar包导入到本地maven库

    1.首先进入cmd,输入maven安装命令,命令如下: mvn install:install-file -Dfile=(jar包的位置) -DgroupId=groupId(分组) -Dartifa ...

  2. AndroidStudio(7)---导入jar包方法

    Android Studio(7)---导入jar包方法 1.首先先去下载需要的jar包 2.将jar包复制到Project下的app–>libs目录下(没有libs目录就新建一个)如下图所示位 ...

  3. 排查maven中可以从远程下载下来jar包,但是却报错Failure to find was cached in the local repository, resolution will not

    一.问题 maven打包的过程中报错如下: Failure to find cfca:backport-util-concurrent:pom:3.1 in http://maven.company. ...

  4. spring原理案例-基本项目搭建 01 spring framework 下载 官网下载spring jar包

    下载spring http://spring.io/ 最重要是在特征下面的这段话,需要注意: All avaible features and modules are described in the ...

  5. 定义任务打印gradle下载的jar包位置

    //定义任务打印gradle下载的jar包位置task showMyCache { configurations.compile.each { println it }} 转载于:https://ww ...

  6. Zeppelin导入额外jar包方法

    Zeppelin导入额外jar包方法 方法一:为特定用户导入特定jar包 方法二:永久导入jar包 方法三:临时导入jar包 方法一:为特定用户导入特定jar包 方法参考这篇博客: zeppelin为 ...

  7. Intellij IDEA--将Java项目打包为jar包--方法/实例

    原文网址:Intellij IDEA--将Java项目打包为jar包--方法/实例_IT利刃出鞘的博客-CSDN博客 简介 本文介绍Idea打包普通Java项目的方法. 本文使用Idea将普通Java ...

  8. IDEA 自动下载依赖jar包

    点击File -> Setting ->Maven ->Importing:选中Automatically download中的两个多选框Sources和Documentation( ...

  9. eclipse导出jar包方法(详细说明)

    目录 1.运行jar包的方法: 2.打jar包的方法:(重点) 3.选项的详细说明(知识拓展) 1.运行jar包的方法: windows使用cmd运行jar 进入到当前目录,执行"java ...

  10. 如何在Spring官网下载各种jar包?

    如何在Spring官网下载各种jar包? 1.浏览器输入地址:https://spring.io ,如下图所示: 然后点击图中的PROJECTS,然后选择自己需要下载的jar包属于哪个分类.我下载的是 ...

最新文章

  1. Python快速入门,你想要的就在这里了!
  2. 力扣算法题—045跳跃游戏二
  3. Android深度探索(卷1)HAL与驱动开发--读书笔记(第一章)
  4. Oracle入门(十四F)之PL/SQL定义变量
  5. 历史上杀伤力最大的笑话!!!
  6. 多益网络与咪咕音乐携手音乐共创 李荣浩领衔唱响神武之夜
  7. 机器学习:LibSVM与weka在eclipse中的使用
  8. 用nginx转发请求tomcat 如何配置访问日志获取真实ip
  9. c语言程序设计考试流程图,c语言程序设计流程图详解.pdf
  10. Hibernate4.3.8Final环境搭建
  11. 毛星云opencv7.1.3之sobel算子--失败算法
  12. esp8266作为wifi中继器
  13. 最新版《神经网络和深度学习》中文版.pdf
  14. 世界城市与北京时差表
  15. TI GEL文件作用
  16. 闰年 判断的两种方式
  17. FL STUDIO 21中文版已经发布啦,有什么新功能?
  18. ReactNative 深层连结
  19. 单片机、嵌入式错综复杂的关系分析
  20. Spring通过xml文件配置AOP,before、after、around、AfterThrowing、AfterReturning、Declare-parents

热门文章

  1. 同城交友小程序项目功能方案介绍
  2. 数据库:关于BULK INSERT 学习笔记(1)
  3. 安全合规/ISO--1--ISO 27000系列标准介绍
  4. 2003-2019年全国30省市分地区能源消费结构数据集(煤炭占比)
  5. 大学生创新创业实务 复习题(无答案)
  6. 解析bt种子下载 java_使用Java解析Torrent文件(BT种子),基于使用Eclipse ECF中的org.eclipse.bittorrent方案...
  7. 软件测试学习资料汇总
  8. 算法设计与分析基础_学习笔记
  9. 华为BFD的配置规范
  10. VM 14 CentOS 7.0虚拟机上网设置方法