Java 编译firebase管理员代码时出错

Java 编译firebase管理员代码时出错,java,firebase,firebase-realtime-database,slf4j,firebase-admin,Java,Firebase,Firebase Realtime Database,Slf4j,Firebase Admin,编译Firebase管理员代码时出错 错误: 根据来自的信息,我尝试一个接一个地添加所有依赖项 添加 testCompile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.13.3' 或 或 或 或 不会删除错误。 我能知道我出了什么问题吗 我的Gradle文件: plugins { id 'java' } group 'org.example' version '1.0-SNAPS

编译Firebase管理员代码时出错

错误:

根据来自的信息,我尝试一个接一个地添加所有依赖项

添加

testCompile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.13.3'

不会删除错误。 我能知道我出了什么问题吗

我的Gradle文件:

plugins {
    id 'java'
}

group 'org.example'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    implementation 'com.google.firebase:firebase-admin:6.13.0'
//None of these seem to remove the error
//    testCompile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.13.3'
//    testCompile group: 'org.slf4j', name: 'slf4j-nop', version: '1.8.0-beta4'
//    testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.8.0-beta4'
//    testCompile group: 'org.slf4j', name: 'slf4j-jdk14', version: '1.8.0-beta4'
//    testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
我的主课

import com.google.auth.oauth2.GoogleCredentials;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import com.google.firebase.database.*;

import java.io.IOException;

public class MainClass {
    public static void main(String[] args) throws IOException {
        FirebaseOptions options = new FirebaseOptions.Builder()
                .setCredentials(GoogleCredentials.getApplicationDefault())
                .setDatabaseUrl("https://{my database name}.firebaseio.com/")
                .build();

        FirebaseApp.initializeApp(options);
        DatabaseReference ref = FirebaseDatabase.getInstance()
                .getReference("restricted_access/secret_document");
        ref.setValue("hiIII", new DatabaseReference.CompletionListener() {
            @Override
            public void onComplete(DatabaseError error, DatabaseReference ref) {
                System.out.println("Completed");
            }
        });
    }
}

我能知道我出了什么问题吗?如何更正它?

当org.slf4j.impl.StaticLoggerBinder类无法加载到内存中时,会报告此警告消息。当在类路径上找不到合适的SLF4J绑定时,就会发生这种情况。将slf4j-nop.jar、slf4j-simple.jar、slf4j-log4j12.jar、slf4j-jdk14.jar或logback-classic.jar中的一个(且仅一个)放在类路径上应该可以解决问题


如果此问题无法解决,请尝试清除缓存并重新启动。

我也尝试过这样做,但不起作用。因为我使用的是Gradle,添加到类路径基本上就是添加它的实现,对吗?是的,这就是我告诉你的原因!另外,我可以知道如何清除intellij IDE中的捕获吗?从主菜单中,选择文件|使缓存无效/重新启动。在“使缓存无效”对话框中,选择一个操作。您可以使缓存无效并重新启动IDE,在不重新启动IDE的情况下使缓存无效,或者只重新启动IDE。
testCompile group: 'org.slf4j', name: 'slf4j-jdk14', version: '1.8.0-beta4'
testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
plugins {
    id 'java'
}

group 'org.example'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    implementation 'com.google.firebase:firebase-admin:6.13.0'
//None of these seem to remove the error
//    testCompile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.13.3'
//    testCompile group: 'org.slf4j', name: 'slf4j-nop', version: '1.8.0-beta4'
//    testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.8.0-beta4'
//    testCompile group: 'org.slf4j', name: 'slf4j-jdk14', version: '1.8.0-beta4'
//    testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
import com.google.auth.oauth2.GoogleCredentials;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import com.google.firebase.database.*;

import java.io.IOException;

public class MainClass {
    public static void main(String[] args) throws IOException {
        FirebaseOptions options = new FirebaseOptions.Builder()
                .setCredentials(GoogleCredentials.getApplicationDefault())
                .setDatabaseUrl("https://{my database name}.firebaseio.com/")
                .build();

        FirebaseApp.initializeApp(options);
        DatabaseReference ref = FirebaseDatabase.getInstance()
                .getReference("restricted_access/secret_document");
        ref.setValue("hiIII", new DatabaseReference.CompletionListener() {
            @Override
            public void onComplete(DatabaseError error, DatabaseReference ref) {
                System.out.println("Completed");
            }
        });
    }
}