代码之家  ›  专栏  ›  技术社区  ›  Martin Delille

包okhttp3.logging不存在

  •  0
  • Martin Delille  · 技术社区  · 5 年前

    我试着用 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
    

    怎么了?

    3 回复  |  直到 5 年前
        1
  •  3
  •   Echoinacup    5 年前

    可能你需要

    <dependency>
        <groupId>com.squareup.okhttp3</groupId>
        <artifactId>logging-interceptor</artifactId>
        <version>3.12.1</version>
    </dependency>
    
        2
  •  0
  •   Vishwa Ratna    5 年前

    okhttp3和okhttp3的版本:记录截取程序依赖项需要完全匹配。例如:

    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    
        3
  •  0
  •   Matteo Tomai    5 年前

    您必须咨询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>