包 okhttp3.logging 不存在
Package okhttp3.logging does not exist
我尝试使用 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
出了什么问题?
可能你需要
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>3.12.1</version>
</dependency>
okhttp3 和 okhttp3:logging-interceptor 依赖项的版本需要完全匹配。例如:
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
您必须查阅 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>
这对我有用:在 gradle 文件中更改下一个配置
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
我尝试使用 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
出了什么问题?
可能你需要
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>3.12.1</version>
</dependency>
okhttp3 和 okhttp3:logging-interceptor 依赖项的版本需要完全匹配。例如:
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
您必须查阅 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>
这对我有用:在 gradle 文件中更改下一个配置
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}