我尝试使用okhttp3.logging
记录我的改造http请求。
我在pom.xml
中添加了依赖项:
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.12.1</version>
</dependency>
不幸的是,我在导入过程中遇到了问题:
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
这是编译时的错误:
ERROR] /Users/martin/dev/adm/usersync/usersync-connectors/usersync-connector-discourse/src/main/java/org/xwiki/contrib/usersync/discourse/internal/DiscourseUserSyncConnector.java:[84,48] package HttpLoggingInterceptor does not exist
出了什么问题?
答案 0 :(得分:3)
可能您需要
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>3.12.1</version>
</dependency>
答案 1 :(得分:0)
需要完全匹配的okhttp3和okhttp3:logging-interceptor依赖项的版本。例如:
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
答案 2 :(得分:0)
您必须查阅Maven资源库站点
https://mvnrepository.com/artifact/com.squareup.okhttp3/logging-interceptor/3.12.1
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/logging-interceptor -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>3.12.1</version>
</dependency>
答案 3 :(得分:0)
这对我有用:在 gradle 文件中更改下一个配置
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}