错误无法加载 class "org.slf4j.impl.StaticLoggerBinder" Apache Kafka
Error Failed to load class "org.slf4j.impl.StaticLoggerBinder" Apache Kafka
我在构建 Java class 和 运行 时遇到错误无法加载 class "org.slf4j.impl.StaticLoggerBinder"。我正在学习 "Apache Kafka Quick Start Guide" 书中的课程。 Java 项目被编译为 gradle 项目。我已将 'slf4j-simple' 包含在 build.gradle 文件中,但错误仍然存在。
我正在输入 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 class 和 运行 时遇到错误无法加载 class "org.slf4j.impl.StaticLoggerBinder"。我正在学习 "Apache Kafka Quick Start Guide" 书中的课程。 Java 项目被编译为 gradle 项目。我已将 'slf4j-simple' 包含在 build.gradle 文件中,但错误仍然存在。
我正在输入 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
。