com.spring.boxes.redis.BoxesRedisConfiguration Maven / Gradle / Ivy
The newest version!
package com.spring.boxes.redis;
import com.spring.boxes.dollar.support.rule.RuleExecutor;
import com.spring.boxes.dollar.support.rule.key.FrequencyTemplate;
import com.spring.boxes.dollar.support.rule.key.GrayScaleTemplate;
import com.spring.boxes.redis.lock.LockTemplate;
import com.spring.boxes.redis.lock.redisson.RedissonLockTemplate;
import com.spring.boxes.redis.lock.redisson.RedissonProperties;
import com.spring.boxes.redis.queue.RedisQueueTemplate;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import javax.annotation.Resource;
@Configuration
@AutoConfigureAfter({RedisAutoConfiguration.class})
@ConditionalOnClass({RedisOperations.class, Config.class})
@EnableConfigurationProperties(RedissonProperties.class)
public class BoxesRedisConfiguration {
@Resource
private ApplicationContext applicationContext;
@Resource
private RedisConnectionFactory redisConnectionFactory;
@Bean(name = {"redisKeySerializer"})
@ConditionalOnMissingBean(name = {"redisKeySerializer"})
public RedisSerializer redisKeySerializer() {
return StringRedisSerializer.UTF_8;
}
@Bean(name = {"redisValueSerializer"})
@ConditionalOnMissingBean(name = {"redisValueSerializer"})
public RedisSerializer