Par*_*ras 5 spring maven okio retrofit2 okhttp3
我正在集成Outlook API,并且为了进行HTTP调用,我使用的是Retrofit版本2.3.0和okHttp3版本3.9.1。 但是,当我进行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;
}
Run Code Online (Sandbox Code Playgroud)
我收到以下异常:
org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: okio.BufferedSource.rangeEquals(JLokio/ByteString;)Z
Run Code Online (Sandbox Code Playgroud)
以下是我的部分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>
Run Code Online (Sandbox Code Playgroud)
有人可以帮我弄清楚,这有什么问题吗?
BufferedSource
Run Code Online (Sandbox Code Playgroud)
位于okio项目版本 1.13.0中。两个依赖项都com.squareup.retrofit2使用com.squareup.okhttp3这个版本。此版本中也包含此方法。从版本来看,它看起来还不错。
当地环境
现在请确保清除您的 Maven 存储库。也许旧版本挂在某个地方。之后执行 Maven 更新项目并进行全新安装。
Tomcat环境
如果您的 tomcat 中发生这种情况,请务必删除该work/Catalina/localhost/文件夹,因为有时东西可能会缓存在那里。
| 归档时间: |
|
| 查看次数: |
5200 次 |
| 最近记录: |