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
Это, по -видимому, указывает на то, что geneicobjectpoolconfig из Apache Commons Pool 2 отсутствует.
Что я пробовал:

проверил, что мой класс конфигурации Redis defined> Breannecnencencenecnecnecnecnecnecnecnecnecnecnecnecnenecnencenecnencenecnencense . Правильно.

очистить и перестроить проект. /> My Build Tool: < /strong> < /p>
Использование Maven (или Gradle) - вот мой фрагмент зависимости для Redis и 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?


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

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