Nexus迁移到阿里云效packages

  1. 点击右上角sign in登录按钮,登录到nexus中
    在这里插入图片描述

  2. 登录后,会出现设置按钮,如图
    在这里插入图片描述

  3. 点击设置按钮,点击左侧的system,点击API,即可打开restFul接口界面
    在这里插入图片描述

  4. 点击打开 Components 组,找到 /v1/components 接口,打开
    在这里插入图片描述

  5. 点击 “Try it out”,然后在 repository *required 的输入框中,输入仓库名称,仓库名称,来源于browse列表
    点击 Execute执行,即可看到相应的下载连接
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

  6. 将上面的回参,下载到本地,点击图中的 download,即可下载回参 json 文件

  7. 将回参拉到底部,查看continuationToken 的值是否为 null,如下如
    在这里插入图片描述

如果不为null,则表示还有下页,如果为null,则表示当前拉取的数据为全部
9. 如果数据有下页。则拿到continuationToken的值,填写到 请求的continuationToken中,继续执行,然后下载json文件,直到返回的continuationToken的值为null为止
在这里插入图片描述

  1. 编写java程序,下载json里面的所有jar以及pom到本地
    a. 核心依赖
    <dependencies>
        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.15.3</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.14.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.11.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.12.0</version>
        </dependency>
    </dependencies>

b. 核心代码

package com.mose;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;

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";

    // 此处若有多个json文件,依次执行即可
    private static final String filePath = "D:\\nexusd\\4.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 (StringUtils.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 = dMap.get("downloadUrl") + "";
                String path = dMap.get("path") + "";
                genFile(url, initPath + path);
            }
        }

    }


    private void genFile(final String urlStr, final String path) {
        System.out.println(path);
        try {
            URL 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();
    }
}
  1. 运行java代码,即可下载所有jar包到本地
    在这里插入图片描述

  2. 迁移
    下载迁移工具
    https://agent-install.oss-cn-hangzhou.aliyuncs.com/migrate-local-repo-tool.jar?file=migrate-local-repo-tool.jar

    执行迁移命令

    java -jar migrate-local-repo-tool.jar -cd "D:/nexusd/" -t https://packages.aliyun.com/maven/repository/111 -u '********' -p '***'
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

mose-x

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值