我想在MAVEN中使用GSON將JSON轉換爲JAVA對象,我遵循YouTube視頻的指導 - https://www.youtube.com/watch?v=Vqgghm9pWe0,但是在主類中發生的錯誤是錯誤 - package com.squareup。 okhttp3不存在。代碼如下:如何解決錯誤 - 包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/,並且試圖用依賴項來構建項目。請幫助:(
安裝下載的,我希望你在你的IDE版本(NetBeans)得到這個錯誤。你試試使用命令行編譯代碼?你可以導航到你的項目。做「mvn clean install」。看起來像自動安裝依賴關係功能沒有啓用。 。 – Eranda