Java.lang.noclassDeffoundError: org/apache/commons/pool2/impl/genericObjectPoolconfig Beim Erstellen von JedisconnectionJava

Java-Forum
Anonymous
 Java.lang.noclassDeffoundError: org/apache/commons/pool2/impl/genericObjectPoolconfig Beim Erstellen von Jedisconnection

Post by Anonymous »

Ich arbeite an einer reaktiven Spring -Boot (3.x) -Anwendung und versuche, Redis mit Jedis zu konfigurieren.

Code: Select all

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jedisConnectionFactory' defined in class path resource [com/myapp/config/RedisConfig.class]: Failed to instantiate [org.springframework.data.redis.connection.jedis.JedisConnectionFactory]: Factory method 'jedisConnectionFactory' threw exception with message: org/apache/commons/pool2/impl/GenericObjectPoolConfig
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/pool2/impl/GenericObjectPoolConfig
Dies scheint anzuzeigen, dass der GenericObjectPoolConfig -Klasse von Apache Commons Pool 2 fehlt. Richtig. /> Mein Build -Tool: < /strong> < /p>
Verwenden von Maven (oder Gradle) - Hier ist mein Abhängigkeits -Snippet für Redis und Jedis: < /p>

org.springframework.boot
spring-boot-starter-data-redis-reactive


org.apache.commons
commons-pool2

< /code>
package com.amit.auth.authservice.configs;

import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.connection.RedisPassword; import org.springframework.data.redis.connection.RedisStandaloneConfiguration; import org.springframework.data.redis.connection.jedis.JedisClientConfiguration; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.serializer.StringRedisSerializer;

@Configuration public class RedisConfig {
@Value("${spring.data.redis.host}")
private String redisHost;

@Value("${spring.data.redis.port}")
private int redisPort;

@Value("${spring.data.redis.password:}")
private String redisPassword;

@Bean
public JedisConnectionFactory jedisConnectionFactory() {
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration(redisHost, redisPort);
if (redisPassword != null && !redisPassword.isBlank()) {
config.setPassword(RedisPassword.of(redisPassword));
}
JedisClientConfiguration clientConfig = JedisClientConfiguration.builder().build();
return new JedisConnectionFactory(config, clientConfig);
}

@Bean
public RedisTemplate redisTemplate(JedisConnectionFactory jedisConnectionFactory) {
RedisTemplate template = new RedisTemplate();
template.setConnectionFactory(jedisConnectionFactory);
template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(new StringRedisSerializer());
template.afterPropertiesSet();
return template;
}
< /code>
}
How to solve that error?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post