gpt4 book ai didi

java - 无法访问com.google.auth.Credentials

转载 作者:行者123 更新时间:2023-12-03 06:25:06 27 4
gpt4 key购买 nike

每当我尝试运行此代码时,我都将Firebase admin SDK与IntelliJ一起使用时,收到以下错误消息:

Error:(15, 50) java: cannot access com.google.auth.Credentials class file for com.google.auth.Credentials not found



这是代码:
import com.google.auth.oauth2.GoogleCredentials;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;

import java.io.FileInputStream;
import java.io.IOException;

public class main {
public static void main (String args[]) throws IOException {
FileInputStream serviceAccount =
new FileInputStream("C:/Users/fusion/Desktop/projects/aesf/google-services.json");

FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials.fromStream(serviceAccount))
.setDatabaseUrl("https://myDataBaseName.firebaseio.com")
.build();

FirebaseApp.initializeApp(options);

}
}

这是 gradle 文件:
plugins {
id 'java'
}

version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.8

repositories {
mavenCentral()
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
implementation 'com.google.firebase:firebase-admin:6.6.0'
implementation 'com.google.auth:google-auth-library-oauth2-http:0.12.0'

}

gradle:
rootProject.name = 'aesf'

最佳答案

检查您是否正在使用其中之一

删除它们

google-oauth-client-1.22.0.jar
google-oauth-client-appengine-1.22.0.jar
google-oauth-client-servlet-1.22.0.jar

还更新您的类路径 classpath 'com.google.gms:google-services:4.2.0'

关于java - 无法访问com.google.auth.Credentials,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53867514/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com