我正在尝试使用 GSON 库来解析我的 Maven 项目中的 JSON 文件。我已将以下依赖项添加到我的 pom.xml 文件中:
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
我正在使用 IntelliJ,我的代码如下所示:
import com.google.gson.*;
public class Import {
Gson gson = new Gson();}
但是,当我运行代码时,出现以下错误:
java.lang.NoClassDefFoundError: com/google/gson/Gson
我不确定是什么导致了这个错误。我该如何解决这个问题并在我的项目中使用 GSON 库?