Okhttp3 com.square不存在

问题描述 投票:-1回答:2

我正在使用Netbeans,我已经用Maven创建了java项目。我添加了这种依赖。

 <dependency>
    <groupId>com.squareup.okhttp</groupId>
    <artifactId>okhttp</artifactId>
    <version>2.7.2</version>
</dependency>

它工作,我可以导入com.squareup.okhttp。*。在网上看到一些代码后,我意识到许多人正在使用版本3+。我试图将包更改为:

更新我在“com.squareup.okhttp”问题中错误地键入了groupid但在我的代码中它是正确的“com.squareup.okhttp3”。

<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.9.0</version>

但我无法导入com.squareup.okhttp3(包com.squareup不存在)。为什么?我是Java语言本身以及支持它的所有IDE和工具的新手。

java maven netbeans-8 okhttp3
2个回答
1
投票

okhttp3的正确坐标是:

<dependency>
    <groupId>com.squareup.okhttp3</groupId>
    <artifactId>okhttp</artifactId>
    <version>3.9.1</version>
</dependency>

请注意,groupId已从com.squareup.okhttp更改为com.squareup.okhttp3

所以,如果你更新你的pom.xml,用我在上面发布的内容替换你对okhttp所拥有的内容,那么你将能够解析okhttp类。

为了将来参考,您可以在okhttp上找到Maven Central文物。


1
投票

导入只是okhttp3:“import okhttp3”没有com.square。

© www.soinside.com 2019 - 2024. All rights reserved.