troyzhxu / okhttps

如艺术一般优雅,像 1、2、3 一样简单,前后端通用,轻量却强大的 HTTP 客户端(同时支持 WebSocket 与 Stomp 协议)
https://ok.zhxu.cn
Apache License 2.0
487 stars 75 forks source link

java.lang.NoSuchFieldError: Companion #65

Closed thegxi closed 2 years ago

thegxi commented 2 years ago

java.lang.NoSuchFieldError: Companion at okhttp3.internal.Util.(Util.kt:70) at okhttp3.internal.concurrent.TaskRunner.(TaskRunner.kt:309) at okhttp3.ConnectionPool.(ConnectionPool.kt:41) at okhttp3.ConnectionPool.(ConnectionPool.kt:47) at okhttp3.OkHttpClient$Builder.(OkHttpClient.kt:471) at com.ejlchina.okhttps.okhttp.OkHttpBuilderImpl.build(OkHttpBuilderImpl.java:231)... Environment: springboot Denpendencies:

com.ejlchina
        <artifactId>okhttps-fastjson</artifactId>
        <version>3.3.2</version>
    </dependency>

Example: HTTP http = HTTP.builder() .baseUrl("https://api.codelife.cc") .build(); http.async("/wallpaper/wallhaven") // http://api.example.com/users/1 .addUrlPara("lang", "cn") .addUrlPara("page", 1) .addUrlPara("sorting", "random") .addUrlPara("topRange", "6M") .addUrlPara("q", "id:2319") .setOnResponse((HttpResult res) -> { // 得到目标数据 List result = res.getBody().toList(WallHavenBO.class); }).get();

troyzhxu commented 2 years ago

请检查项目使用的 okhttp 是什么版本,应该是底层的 okhttp 版本太低了。

thegxi commented 2 years ago

谢谢,解决了

miozus commented 2 months ago

我无语了,升级适配版本指定未解决,koltlin 升级到 2.0.10 就可以了:我的组合拳

okhttp3 4.12.0 kotlin 2.0.10 okio 3.9.0

https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp/4.12.0