新的 JedisPool 出现 NoClassDefFoundError
new JedisPool is getting a NoClassDefFoundError
我要创建一个 Jedis 池,(以一种非常简单的方式)
但我收到以下错误:
public static void main(String[] args) {
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxTotal(10);
new JedisPool(jedisPoolConfig, "localhost");
}
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at redis.clients.jedis.HostAndPort.<clinit>(HostAndPort.java:12)
at redis.clients.jedis.JedisFactory.<init>(JedisFactory.java:58)
at redis.clients.jedis.JedisFactory.<init>(JedisFactory.java:50)
at redis.clients.jedis.JedisFactory.<init>(JedisFactory.java:36)
at redis.clients.jedis.JedisPool.<init>(JedisPool.java:221)
at redis.clients.jedis.JedisPool.<init>(JedisPool.java:165)
at redis.clients.jedis.JedisPool.<init>(JedisPool.java:137)
at redis.clients.jedis.JedisPool.<init>(JedisPool.java:76)
at redis.clients.jedis.JedisPool.<init>(JedisPool.java:120)
at redis.clients.jedis.JedisPool.<init>(JedisPool.java:103)
at redis.clients.jedis.JedisPool.<init>(JedisPool.java:22)
at JedisPoolUtils.main(JedisPoolUtils.java:17)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 12 more
Jedis 有 slf4j-api 作为编译依赖,您需要将 slf4j-api jar 添加到您的应用程序
我要创建一个 Jedis 池,(以一种非常简单的方式)
但我收到以下错误:
public static void main(String[] args) {
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxTotal(10);
new JedisPool(jedisPoolConfig, "localhost");
}
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at redis.clients.jedis.HostAndPort.<clinit>(HostAndPort.java:12)
at redis.clients.jedis.JedisFactory.<init>(JedisFactory.java:58)
at redis.clients.jedis.JedisFactory.<init>(JedisFactory.java:50)
at redis.clients.jedis.JedisFactory.<init>(JedisFactory.java:36)
at redis.clients.jedis.JedisPool.<init>(JedisPool.java:221)
at redis.clients.jedis.JedisPool.<init>(JedisPool.java:165)
at redis.clients.jedis.JedisPool.<init>(JedisPool.java:137)
at redis.clients.jedis.JedisPool.<init>(JedisPool.java:76)
at redis.clients.jedis.JedisPool.<init>(JedisPool.java:120)
at redis.clients.jedis.JedisPool.<init>(JedisPool.java:103)
at redis.clients.jedis.JedisPool.<init>(JedisPool.java:22)
at JedisPoolUtils.main(JedisPoolUtils.java:17)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 12 more
Jedis 有 slf4j-api 作为编译依赖,您需要将 slf4j-api jar 添加到您的应用程序