com.emily.infrastructure.redis.RedisDbReactiveAutoConfiguration Maven / Gradle / Ivy
The newest version!
package com.emily.infrastructure.redis;
import com.emily.infrastructure.redis.factory.BeanFactoryProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Role;
import org.springframework.core.io.ResourceLoader;
import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory;
import org.springframework.data.redis.core.ReactiveRedisTemplate;
import org.springframework.data.redis.core.ReactiveStringRedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializationContext;
import org.springframework.data.redis.serializer.RedisSerializer;
import reactor.core.publisher.Flux;
import java.util.Map;
import java.util.Objects;
import static com.emily.infrastructure.redis.common.RedisBeanNames.*;
/**
* @author : Emily
* @since : 2023/9/25 21:51 PM
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@AutoConfiguration(after = {RedisDbAutoConfiguration.class})
@ConditionalOnClass({ReactiveRedisConnectionFactory.class, ReactiveRedisTemplate.class, Flux.class})
public class RedisDbReactiveAutoConfiguration implements InitializingBean, DisposableBean {
private final RedisDbProperties redisDbProperties;
public RedisDbReactiveAutoConfiguration(RedisDbProperties redisDbProperties) {
this.redisDbProperties = redisDbProperties;
}
@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@ConditionalOnMissingBean(name = DEFAULT_REACTIVE_REDIS_TEMPLATE)
@ConditionalOnBean(ReactiveRedisConnectionFactory.class)
public ReactiveRedisTemplate