com.itxiaoer.commons.redis.RedisConfig Maven / Gradle / Ivy
package com.itxiaoer.commons.redis;
import com.itxiaoer.commons.redis.sentinel.RedisSentinelConfig;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
/**
* @author : liuyk
*/
@Configuration
@SuppressWarnings("all")
@ConditionalOnMissingBean(RedisSentinelConfig.class)
public class RedisConfig {
@Bean
JedisConnectionFactory jedisConnectionFactory() {
return new JedisConnectionFactory();
}
@Bean
public RedisTemplate redisTemplate() {
RedisTemplate template = new RedisTemplate<>();
template.setConnectionFactory(jedisConnectionFactory());
return template;
}
}