我试图在MAVEN中使用GSON将JSON转换成JAVA对象,我正在跟踪一个youtube视频以获得指导-- https://www.youtube.com/watch?v=Vqgghm9pWe0,但是当在主类中错误是包com.squareup.okhttp3不存在时,就会发生错误。守则如下:
Java
package com.codebeasty.json;
import com.squareup.okhttp3.OkHttpClient;
public class Main {
private static OkHttpClient client = new OkHttpClient();
public static void main (String [] args)
{
}
}我甚至在pom.xml中添加了依赖项:
<dependencies>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>
</dependencies>我不明白为什么它不承认com.squareup。有什么额外的东西需要我下载吗?我已经从这个网站下载了JAR - http://square.github.io/okhttp/,并且尝试用依赖关系构建这个项目。请帮助:(
发布于 2016-11-05 16:04:39
马文回购有最新版本3.4.1。尝试更改pom中的版本,或使用
mvn install:install-file -Dfile=path/to/okhttp-3.4.2.jar -DgroupId=com.squareup.okhttp3 -DartifactId=okhttp -Dversion=3.4.2 -Dpackaging=jarhttps://stackoverflow.com/questions/40440288
复制相似问题