Closed edwardlau closed 2 years ago
SpringBoot 里的依赖,将 okhttp 排除试试?
<exclusions>
<exclusion>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</exclusion>
</exclusions>
看看是哪些 dependency 依赖了 okhttp3,把他们排除一下,依赖的查找可以用 IDEA 的 Dependency Analyzer,找到低版本的 okhttp,右键 exclude
可以参考一下这个,你们可以根据项目的实际情况排除冲突的依赖
<dependency>
<groupId>com.tencentcloudapi</groupId>
<artifactId>tencentcloud-sdk-java</artifactId>
<version>3.1.423</version>
<exclusions>
<exclusion>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.qiniu</groupId>
<artifactId>qiniu-java-sdk</artifactId>
<version>7.2.23</version>
<exclusions>
<exclusion>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</exclusion>
</exclusions>
</dependency>
已解决,发现是版本管理问题,我们用了spring-boot-dependencies这个管理默认是 3.14.9,我把 4.9.3的贴过去就好了
好的
Spring 限制了 okhttp3 的版本,导致该sdk内的okhttps3版本失效。 https://docs.spring.io/spring-boot/docs/2.6.11/reference/htmlsingle/#appendix.dependency-versions.coordinates
简单处理方式: 将此sdk的okhttps的依赖copy到自己工程,将对应版本的okhttp3引入到工程内,maven就近原则会先使用你所依赖的okhttp3版本
springboot 默认使用 okhttp3 3.14.9 本 jar 使用 4.9.3 使用时候会出现找不到对应方法。