找不到com.google.auth.credentials的java类文件

mwngjboj  于 2021-06-29  发布在  Java
关注(0)|答案(1)|浏览(381)

我不能在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>
yyhrrdl8

yyhrrdl81#

我发现“firebase admin”依赖项有另一个版本的“googleoauth客户端”。尝试从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>

检查这种情况的一个好方法是运行mvndependency:tree -dverbose 在控制台里。
编辑-发布响应
我发现过去也有类似的问题。这是链接

相关问题