package com.sptg.common.security.cfgbeans;

import org.springframework.beans.factory.annotation.Autowired;
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.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;

/**
 * title: SecurityConfigBean
 * package: com.sptg.common.security.cfgbeans
 * description: 安全配置
 *
 *                  
 *                 
 */
@Configuration
public class SecurityConfigBean {

    @Bean(name = "redisTemplate")
    @ConditionalOnMissingBean(value = RedisTemplate.class)
    public RedisTemplate<Object, Object> redisTemplate(@Autowired RedisConnectionFactory redisConnectionFactory){
        RedisTemplate<Object, Object> template = new RedisTemplate<>();
        template.setConnectionFactory(redisConnectionFactory);
        template.setDefaultSerializer(new GenericJackson2JsonRedisSerializer());
        return template;
    }

}
