我遇到了抛出此错误的datastax cassandra驱动程序:
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.datastax.driver.core.Cluster.<clinit>(Cluster.java:63)
at Main.main(Main.java:13)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
Process finished with exit code 1
我用gradle导入了库,我看到org.slf4j:slf4j-api:1.7.5位于&#34;外部库&#34;树(我正在使用Intellij IDEA)。
group 'com.test'
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.5
repositories {
mavenCentral()
}
dependencies {
compile 'com.datastax.cassandra:cassandra-driver-core:2.1.6'
compile 'org.slf4j:slf4j-log4j12:1.7.5'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
你有什么想法解决这个问题吗?我发现这篇文章接近我的问题(NoClassDefFoundError - datastax java driver for Cassandra),但没有人正确回复。
谢谢。
答案 0 :(得分:0)
您需要添加为依赖项org.slf4j:slf4j-log4j12:1.7.5