Java.lang.noclassdeffounderror: org/apache/commons/pool2/impl/genericobjectpoolconfig при создании jedisconnectionFactorJAVA

Программисты JAVA общаются здесь
Anonymous
Java.lang.noclassdeffounderror: org/apache/commons/pool2/impl/genericobjectpoolconfig при создании jedisconnectionFactor

Сообщение Anonymous »

Я работаю над реактивным приложением Spring Boot (3.x) и пытаюсь настроить Redis с использованием jedis. < /p>
Во время запуска приложения я получаю следующую ошибку: < /p>

Код: Выделить всё

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
Это, по -видимому, указывает на то, что класс GenericObjectPoolConfig из Apache Commons Pool 2 отсутствует.
То, что я пробовал:
подтвердил, что мой класс конфигурации jedisconnectory определял Propected и Probured. /> Googled the Erry и обнаружил, что Commons-Pool2 является обязательной зависимостью, но она не включена в мой проект транзисивно.
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>
}
Please help!!!
Thank You,
Amit
I want resolve this error.

Подробнее здесь: https://stackoverflow.com/questions/797 ... bjectpoolc

Вернуться в «JAVA»