为 firebase admin 编译代码时出错

Error while compiling code for firebase admin

我在为 Firebase 管理员编译代码时遇到错误。

错误:

根据 http://www.slf4j.org/codes.html#StaticLoggerBinder 的信息,我已经尝试添加所有依赖项 一个一个

添加

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'

没有消除错误。 我可以知道我出了什么问题吗?

我的 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'

我的主要Class

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 class 加载到内存中时,将报告此警告消息。当在 class 路径上找不到合适的 SLF4J 绑定时,就会发生这种情况。在 class路径应该可以解决问题。

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