英文:
Error while compiling code for firebase admin
问题
以下是您提供的内容的翻译部分:
错误:
根据 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'
// 这些依然无法解决错误
// 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://{我的数据库名称}.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("完成");
}
});
}
}
请问我错在了哪里?我该如何纠正呢?
英文:
I got an error while compiling code for Firebase admin.
Error:
Following the info from <http://www.slf4j.org/codes.html#StaticLoggerBinder> I've tried adding all the dependencies one by one
adding
testCompile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.13.3'
or
testCompile group: 'org.slf4j', name: 'slf4j-nop', version: '1.8.0-beta4'
or
testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.8.0-beta4'
or
testCompile group: 'org.slf4j', name: 'slf4j-jdk14', version: '1.8.0-beta4'
or
testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
doesn't remove the error.
May I know what I'm going wrong with?
My Gradle file:
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'
My main 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");
}
});
}
}
May I know What I'm going wrong with? and How can I Correct it?
答案1
得分: 1
这个警告消息是在无法将 org.slf4j.impl.StaticLoggerBinder 类加载到内存时报告的。当类路径上找不到适当的 SLF4J 绑定时会发生这种情况。在类路径上放置 slf4j-nop.jar、slf4j-simple.jar、slf4j-log4j12.jar、slf4j-jdk14.jar 或 logback-classic.jar 中的一个(仅限一个),应该可以解决这个问题。
如果这个问题没有解决,请尝试清除缓存并重新启动。
英文:
This warning message is reported when the org.slf4j.impl.StaticLoggerBinder class could not be loaded into memory. This happens when no appropriate SLF4J binding could be found on the class path. Placing one (and only one) of slf4j-nop.jar slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar on the class path should solve the problem.
If this problem doesnot solve try clear caches and restart.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论