【exception】NoSuchMethodError kotlin.collections.ArraysKt.copyInto([B[BIII)[B_非正常人研究室-CSDN博客 - 正解 亲测可用

现象

本地在IDEA上使用okhttp的时候没有问题,在给同事用的时候发现一直报这个错误,并且几个同事出现的可能性都不一样。怀疑跟IDEA的版本有问题,因为抛出的异常跟IDEA的包有关系。

解决

在pom.xml中加入

<!-- https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib -->
<dependency>
    <groupId>org.jetbrains.kotlin</groupId>
    <artifactId>kotlin-stdlib</artifactId>
    <version>1.3.70</version>
</dependency>
package cn.superdesk.uniorder.ex.patch.controller.call;


import cn.hutool.core.date.DateUtil;
import cn.hutool.core.thread.ThreadUtil;
import cn.superdesk.uniorder.libs.common.logger.ExceptionUtils;
import cn.superdesk.uniorder.libs.common.network.OkHttpUtils;
import lombok.extern.slf4j.Slf4j;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;
import java.util.concurrent.ExecutorService;

/**
 * @Description: 推送区间时间内所有订单数据

 * @Author: linjinyu
 * @CreateDate: 10/10/20 11:25 AM
 * @UpdateUser: linjinyu
 * @UpdateDate: 10/10/20 11:25 AM
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */

@Slf4j
public class _CallWelfareOctlifeCn extends ApiBaseUtils {

    public static String RELATIVE_PATH = "/推单";
    public static String TASK_PATH     = "/任务";

    private static ExecutorService executorService = ThreadUtil.newExecutor(1, 1);

    public static void main(String[] args) {

        String startAt = "2020-09-01 0:0:0";
//        String startAt = "2020-10-10 11:00:00";
        String endAt   = "2020-10-10 12:00:00";

        String taskAt = "2020-10-10 12:00:00";


        Long startAtLong = getUnixTimeStamp(startAt);
        Long endAtLong   = getUnixTimeStamp(endAt);

        log.info("\ninit ... startAt: {} {}, endAt: {} {}", startAt, startAtLong, endAt, endAtLong);

//        // 任务 开始前
        TASK_PATH = createTaskPath(taskAt, startAt, endAt);
//
        final int limit = 3600;
//
        for (long i = Long.parseLong(startAtLong.toString()); i <= Long.parseLong(endAtLong.toString()); i += limit) {
            final long offset = i;
            executorService.execute(() -> run(offset, limit, startAtLong, endAtLong));
        }

        executorService.shutdown();

//        done();

    }

    public static void run(long offset, long limit, Long startAt, Long endAt) {

        long stateTime = offset;
        long endTime   = offset + limit;

        log.info("\n\n\n\n" +
                        "===============================================" +
                        "\ncall init ... " +
                        "\noffset: {} {} " +
                        "\nlimit: {} {} " +
                        "\nstartAt: {} {} " +
                        "\nendAt: {} {}\n" +
                        "===============================================" +
                        "\n\n\n\n",
                stateTime, DateUtil.date(stateTime * 1000),
                endTime, DateUtil.date(endTime * 1000),
                startAt, DateUtil.date(startAt * 1000),
                endAt, DateUtil.date(endAt * 1000)
        );

        String filePath = getFileFullPathAndMk(RELATIVE_PATH + TASK_PATH, getFileNameByStateTimeEndTime(offset, limit));

        if (!checkFileIsExist(filePath)) {

            try {

                log.info("\ncall ... 同步请求 ... {}\n", Thread.currentThread().getName());

                String url = "" + stateTime + "&endtime=" + endTime;

                log.info("\n{}",url);


//                OkHttpClient client = new OkHttpClient().newBuilder()
//                        .build();
//                Request request = new Request.Builder()
//                        .url(url)
//                        .method("GET", null)
//                        .addHeader("Cookie", "PHPSESSID=4c29bb597e3e3ab0a8328b7bb779a51d")
//                        .build();
//                Response response = client.newCall(request).execute();


                OkHttpClient client = OkHttpUtils.getInstance();
                Request request = new Request.Builder()
                        .url(url)
                        .method("GET", null)
                        .addHeader("X-API-KEY", X_API_KEY)
                        .addHeader("Cookie", COOKIE)
                        .build();
                Response response = client.newCall(request).execute();

                String json = response.body().string();

                response(filePath, json);

            } catch (Exception ioe) {
                log.info(ExceptionUtils.getMessage(ioe));
            }
        }
    }
}

指定kotlib-stdlib的版本,我的问题解决了。我看到别的解决方法中还有指定版本是1.3.50的,所以如果1.3.70不行,那就换成1.3.50试试。


Original url: Access
Created at: 2020-10-10 12:27:39
Category: default
Tags: none

请先后发表评论
  • 最新评论
  • 总共0条评论