doocs / qcloud-im-server-sdk-java

☁ Tencent Cloud IM Server SDK in Java | 腾讯云 IM 服务端 SDK Java 版
https://doocs.github.io/qcloud-im-server-sdk-java
Apache License 2.0
109 stars 40 forks source link

OKhttp3 版本跟 springboot2.5.2的版本有冲突 #103

Closed edwardlau closed 2 years ago

edwardlau commented 2 years ago

springboot 默认使用 okhttp3 3.14.9 本 jar 使用 4.9.3 使用时候会出现找不到对应方法。

image
yanglbme commented 2 years ago

SpringBoot 里的依赖,将 okhttp 排除试试?

<exclusions>
    <exclusion>
        <groupId>com.squareup.okhttp3</groupId>
        <artifactId>okhttp</artifactId>
    </exclusion>
</exclusions>
yanglbme commented 2 years ago

看看是哪些 dependency 依赖了 okhttp3,把他们排除一下,依赖的查找可以用 IDEA 的 Dependency Analyzer,找到低版本的 okhttp,右键 exclude

yanglbme commented 2 years ago

可以参考一下这个,你们可以根据项目的实际情况排除冲突的依赖

<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>
edwardlau commented 2 years ago

已解决,发现是版本管理问题,我们用了spring-boot-dependencies这个管理默认是 3.14.9,我把 4.9.3的贴过去就好了

yanglbme commented 2 years ago

好的

CoolBlackJF commented 1 year ago

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版本