我正在集成Outlook API并使用Retrofit版本2.3.0和okHttp3版本3.9.1进行HTTP调用。但是,当我进行HTTP调用时,例如:
// Create a logging interceptor to log request and responses
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel( HttpLoggingInterceptor.Level.BODY );
OkHttpClient client = new OkHttpClient.Builder().addInterceptor( interceptor ).build();
// Create and configure the Retrofit object
Retrofit retrofit = new Retrofit.Builder().baseUrl( authority ).client( client ).addConverterFactory( JacksonConverterFactory.create() ).build();
// Generate the token service
TokenService tokenService = retrofit.create( TokenService.class );
try
{
return tokenService.getAccessTokenFromAuthCode( tenantId, getAppId(), getAppPassword(), "authorization_code", authCode, getRedirectUrl() ).execute().body();
}
catch ( IOException e )
{
TokenResponse error = new TokenResponse();
error.setError( "IOException" );
error.setErrorDescription( e.getMessage() );
return error;
}
我得到了以下异常:
org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: okio.BufferedSource.rangeEquals(JLokio/ByteString;)Z
下面是我的部分pom.xml:
<!-- JACKSON DEPENDENCY FOR JSON PARSING -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.3</version>
</dependency>
<!-- RETROFIT DEPENDENCY FOR SENDING HTTP REQUESTS -->
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>retrofit</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>converter-jackson</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>3.9.1</version>
</dependency>
有人能帮我弄清楚这是怎么回事吗?
发布于 2018-01-16 18:20:01
BufferedSource
是在okio项目版本1.13.0中。依赖项com.squareup.retrofit2
和com.squareup.okhttp3
都使用此版本。此外,在此版本中还包括此方法。就版本而言,它看起来还不错。
本地环境
现在,请确保清除maven存储库。也许是旧版本挂在了什么地方。在那之后,做一个maven更新项目和干净的安装。
Tomcat环境
如果在tomcat中发生这种情况,也请确保删除work/Catalina/localhost/
文件夹,因为有时数据可能会被缓存在那里。
发布于 2021-10-20 15:18:09
在通过YARN执行MapReduce作业时,我遇到了类似的问题。在我的例子中,存在一个现有的降级的okio版本,它覆盖了应用程序的外部库。我把它改成了okio 1.13.0,这个问题已经解决了。
对我来说就是这个位置:
/home/vagrant/bigdata/hadoop/share/hadoop/hdfs/lib
发布于 2018-11-26 23:36:23
这可能是因为与依赖项提供的现有Okio
版本冲突。
请看Spark and Influx: OKIO conflict,这与Apache Spark有冲突。
使用Maven / Gradle dep.树导出以查看所有可传递的详细信息,或者(在我的示例中):
jar tf /usr/hdp/current/spark-client/lib/spark-assembly-1.6.3.2.6.3.0-235-hadoop2.7.3.2.6.3.0-235.jar | grep okio
这将列出:
okio/BufferedSource.class
然后解压okhttp
pom.xml:
jar xf /usr/hdp/current/spark-client/lib/spark-assembly-1.6.3.2.6.3.0-235-hadoop2.7.3.2.6.3.0-235.jar META-INF/maven/com.squareup.okhttp/okhttp/pom.xml
cat META-INF/maven/com.squareup.okhttp/okhttp/pom.xml | grep version
https://stackoverflow.com/questions/48277426
复制相似问题