0

With the latest releases of Spring Boot 3.0.4, native-maven-plugin-0.9.20, and spring-boot-starter-data-redis-reactive-3.0.4

I have a Redis configuration using the RedisConfig code as shown above.

@Configuration
public class RedisConfig {

    @Value("${spring.redis.host}")
    private String host;

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

    @Bean
    public ReactiveRedisConnectionFactory reactiveRedisConnectionFactory() {
        return new LettuceConnectionFactory(host, port);
    }

    @Bean
    public RedisClient redisClient(){
        ClientOptions options = ClientOptions.builder()
                .autoReconnect(true)
                .build();
        RedisClient redisClient = RedisClient.create("redis://"+host+":"+port);
        redisClient.setOptions(options);
        return redisClient;
    }

    @Bean
    public RedisReactiveCommands<String, String> redisReactiveCommands() {
        return redisClient().connect().reactive();
    }
}

However, when I try to compile with Maven "mvn native:compile -Pnative" & run the Spring Boot application using native image , I encounter a problem with the exception

"Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reactiveRedisConnectionFactory': null". 

But, when I run the application using JVM, everything runs smoothly. Am I missing something?

I have tried updating the Redis and Spring Framework dependency versions, as well as updating the RedisConfig configuration. I also tried searching for solutions in forums and Spring documentation, but have not found a suitable solution. I hope to find a solution or suggestion that can help me overcome the exception problem that occurs when running a Spring Boot application with a native image using the RedisConfig configuration above.

0 Answers0