编译firebase管理员代码时出错

问题描述 投票:-1回答:1

我在编译Firebase管理员的代码时出现了错误。

错误。

enter image description here

根据以下信息 http:/www.slf4j.orgcodes.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'

我的主类

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");
            }
        });
    }
}

我想知道我到底是哪里出了问题,怎么才能改正?

java firebase firebase-realtime-database slf4j firebase-admin
1个回答
1
投票

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

如果这个问题不能解决,请尝试清除缓存并重新启动。

© www.soinside.com 2019 - 2024. All rights reserved.