【问题标题】:No Such Method Error exception thrown while using OK Http 3 with IPinfo?使用带有 IPinfo 的 OK Http 3 时没有抛出此类方法错误异常?
【发布时间】:2021-10-13 14:10:51
【问题描述】:

我正在从 IP Info 运行 Java 客户端库。当我尝试执行代码时:

IPinfo ipInfo = new IPinfo.Builder().setToken(apiKey).build();
IPResponse response = ipInfo.lookupIP(ipAddress);

我得到一个java.lang.NoSuchMethodError: okhttp3.Response.close()V 异常。

我尝试将OK Http 3 的版本从5.0.0-alpha.2 显式更改为5.0.0-alpha.14.9.0(也尝试了许多其他版本),但它们都产生了相同的错误。

是什么导致了这个错误?我应该使用哪个版本来访问上述方法?

我的 POM 文件有以下依赖项:

<dependencies>

<dependency>
 <groupId>org.controlsfx</groupId>
 <artifactId>controlsfx</artifactId>
 <version>8.40.14</version>
</dependency>

<dependency>
 <groupId>co.ipdata.client</groupId>
 <artifactId>ipdata-java-client</artifactId>
 <version>0.2.0</version>
</dependency>


<dependency>
 <groupId>com.fasterxml.jackson.core</groupId>
 <artifactId>jackson-databind</artifactId>
 <version>2.9.8</version>
</dependency>

<dependency>
 <groupId>io.ipinfo</groupId>
 <artifactId>ipinfo-api</artifactId>
 <version>2.0</version>
</dependency>

<dependency>
 <groupId>com.squareup.okhttp3</groupId>
 <artifactId>okhttp</artifactId>
 <version>4.9.0</version>
</dependency>

更新:

也许更有趣的是,我注意到当我在 Eclipse 中打开上述行时出现错误

at io.ipinfo.api.request.IPRequest.handle(IPRequest.java:34)

它指向io.ipinfo.api.request; 中的第 34 行,但该行完全没有代码。该行仅包含大括号的结尾。请看下面的截图:

【问题讨论】:

    标签: java eclipse maven dependencies


    【解决方案1】:

    感谢大家的所有建议和意见!我终于自己找到了答案。。

    事实证明,这个项目依赖于一个不同的项目,其中包括以下 maven 依赖项:

        <dependency>
            <groupId>com.squareup.retrofit</groupId>
            <artifactId>retrofit</artifactId>
            <version>1.9.0</version>
        </dependency>
        
        
        
        <dependency>
            <groupId>com.squareup.okhttp</groupId>
            <artifactId>okhttp</artifactId>
            <version>2.7.5</version>
        </dependency>
        
        
        <dependency>
            <groupId>com.squareup.retrofit2</groupId>
            <artifactId>retrofit</artifactId>
            <version>2.0.2</version>
        </dependency>
        
    

    我删除了那些 Maven 依赖项,现在一切正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-16
      • 1970-01-01
      • 1970-01-01
      • 2021-03-31
      • 2015-07-11
      • 2019-08-30
      相关资源
      最近更新 更多