【问题标题】:class file for com.google.auth.Credentials not found未找到 com.google.auth.Credentials 的类文件
【发布时间】:2020-12-27 17:33:08
【问题描述】:

我无法在 Firebaseoptions 中使用 GoogleCredentials。使用 Maven 导出时出现以下错误:

  class file for com.google.auth.Credentials not found

 FirebaseOptions options = FirebaseOptions.builder()

                    .setCredentials(GoogleCredentials.fromStream(serviceAccount))
                    // Your Database URL can be found in your firebase console -> your project
                    .setDatabaseUrl("https://health-45311.firebaseio.com/")
                    .build();

在 Intellij 中我无法导入包,但是当我使用 Maven 导出时没有任何效果。

我的 pom.xml

 <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>15.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>15.0.1</version>
        </dependency>

        <dependency>
            <groupId>com.google.firebase</groupId>
            <artifactId>firebase-admin</artifactId>
            <version>7.1.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.google.oauth-client/google-oauth-client -->
        <dependency>
            <groupId>com.google.oauth-client</groupId>
            <artifactId>google-oauth-client</artifactId>
            <version>1.31.2</version>
        </dependency>




    </dependencies>

【问题讨论】:

    标签: java firebase maven javafx firebase-admin


    【解决方案1】:

    我发现 "firebase-admin" 依赖项有另一个版本的 "google-oauth-client"。尝试从 pom 中排除

        <dependency>
            <groupId>com.google.firebase</groupId>
            <artifactId>firebase-admin</artifactId>
            <version>7.1.0</version>
            <exclusions>
                <exclusion>
                    <groupId>com.google.oauth-client</groupId>
                    <artifactId>google-oauth-client</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    

    检查这类事情的一个好方法是在控制台中运行 mvn dependency:tree -Dverbose

    编辑 - 发布回复

    我发现以前有一个类似的问题。 Here is the link

    【讨论】:

      猜你喜欢
      • 2019-03-11
      • 2020-04-20
      • 2018-11-10
      • 2016-10-30
      • 2018-06-10
      • 1970-01-01
      • 2016-03-23
      • 2018-07-17
      • 1970-01-01
      相关资源
      最近更新 更多