未找到 Google GSON 依赖项

Aus*_*ley 2 java intellij-idea maven gson

我试图在我的 pom.xml 中包含 GSON,但 IntelliJ 告诉我没有找到依赖项“com.google.code.gson:gson:2.8.0”。我曾尝试调用 Maven 存储库,但它仍然无法正常工作。还要忽略注释掉的行。

这是我的 pom 文件的副本。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>TagChooser</groupId>
<artifactId>TagChooser 1.7.10</artifactId>
<version>1.0-SNAPSHOT</version>


<dependencies>

    <!--  Gson: Java to Json conversion -->
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.8.0</version>
        <scope>compile</scope>
    </dependency>

    <!--<dependency>-->
        <!--<groupId>mkremins</groupId>-->
        <!--<artifactId>fanciful</artifactId>-->
        <!--<version>0.4.0-SNAPSHOT</version>-->
    <!--</dependency>-->

</dependencies>

<repositories>
    <repository>
        <id>central</id>
        <name>Maven repository</name>
        <url>http://repo1.maven.org/maven2</url>
    </repository>

    <!--<repository>-->
        <!--<id>stealthyone-repo</id>-->
        <!--<url>http://repo.stealthyone.com/content/groups/public</url>-->
    <!--</repository>-->

</repositories>
Run Code Online (Sandbox Code Playgroud)

Aus*_*ley 6

我记得如何快速做到这一点。您必须转到文件-> 项目结构。然后单击库选项卡和绿色加号。单击后从 Maven 中选择,然后搜索 GSON 并从菜单中找到您要使用的正确 GSON 版本,然后 GSON 依赖项将起作用。


Chr*_*447 5

我遇到过同样的问题。

转到文件 -> 使缓存无效/重新启动,然后再次单击相同的按钮。

Android Studio 会重新启动并重新加载所有库文件。