当我构建 Java 类并运行时,我遇到错误无法加载类“org.slf4j.impl.StaticLoggerBinder”。我正在遵循《Apache Kafka 快速入门指南》一书的类(class)。 Java项目被编译为gradle项目。我已经在 build.gradle 文件中包含“slf4j-simple”,但错误仍然存在。
我正在输入 gradle jar
来构建 .jar 文件。
错误:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for
further details.
还有 build.gradle:
apply plugin: 'java'
apply plugin: 'application'
sourceCompatibility = '1.8'
mainClassName = 'monedero.ProcessingEngine'
repositories {
mavenCentral()
}
version = '0.1.0'
dependencies {
compile group: 'org.apache.kafka', name: 'kafka_2.12', version:
'2.0.0'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core',
version: '2.9.7'
testCompile group: 'org.slf4j', name: 'slf4j-simple', version:
1.6.1'
}
jar {
manifest {
attributes 'Main-Class': mainClassName
} from {
configurations.compile.collect {
it.isDirectory() ? it : zipTree(it)
}
}
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
最佳答案
您需要将 testCompile
更改为 compile
以便主应用程序加载这些类。
关于java - 错误无法加载类 "org.slf4j.impl.StaticLoggerBinder"Apache Kafka,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56829218/