3 Star 36 Fork 17

lzhpo / chatgpt-spring-boot-starter

 / 详情

springboot2.6.12版本okhttp3兼容报错,求助

已完成
创建于  
2023-07-12 10:11

默认报错:
"Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: okhttp3.RequestBody.create(Ljava/lang/String;Lokhttp3/MediaType;)Lokhttp3/RequestBody;",
换低版本okhttp3也是报这错。

换高版本报错:Exception in thread "OkHttp Dispatcher" java.lang.NoSuchFieldError: instance

:sob: 有啥解决办法吗

评论 (2)

刘仕杰 创建了任务

@刘仕杰 @曾宇仔 不好意思,最近太忙了,没注意看消息。
SpringBoot-2.6.x内置的是okhttp-3.x(源码是Java),我这里用的是okhttp-4.x(源码是Kotiln),且用了4.x的一些新特性,所以导致版本冲突了。

如果不能升级SpringBoot,将以下这个版本管理加入到你的pom.xml里面即可,版本可以和chatgpt-spring-boot-starter的okhttp版本保持一致:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>4.10.0</version>
        </dependency>
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp-sse</artifactId>
            <version>4.10.0</version>
        </dependency>
    </dependencies>
</dependencyManagement>
lzhpo 任务状态待办的 修改为进行中
lzhpo 任务状态进行中 修改为已完成

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(3)
2136520 lzhpo 1578966988 11636226 liushijie kitie 1709961115
1
https://gitee.com/lzhpo/chatgpt-spring-boot-starter.git
git@gitee.com:lzhpo/chatgpt-spring-boot-starter.git
lzhpo
chatgpt-spring-boot-starter
chatgpt-spring-boot-starter

搜索帮助