// Path: jbase-spring/src/main/java/com/jayqqaa12/jbase/spring/serialize/RedisJsonSerializer.java
// public class RedisJsonSerializer<T> implements RedisSerializer<T> {
// 
// 
// 	private static final SerializerFeature[] features = {
// 			SerializerFeature.WriteEnumUsingToString,
// 			SerializerFeature.SortField, SerializerFeature.SkipTransientField,
// 			SerializerFeature.WriteClassName };
// 
// 	private static final Feature[] DEFAULT_PARSER_FEATURE = {
// 			Feature.AutoCloseSource, Feature.InternFieldNames,
// 			Feature.AllowUnQuotedFieldNames, Feature.AllowSingleQuotes,
// 			Feature.AllowArbitraryCommas, Feature.SortFeidFastMatch,
// 			Feature.IgnoreNotMatch };
// 
// 	@Override
// 	public byte[] serialize(Object t) throws SerializationException {
// 		return JSON.toJSONBytes(t, features);
// 	}
// 
// 	@SuppressWarnings("unchecked")
// 	@Override
// 	public T deserialize(byte[] bytes) throws SerializationException {
// 		if (bytes == null)
// 			return null;
// 		return (T) JSON.parse(bytes, DEFAULT_PARSER_FEATURE);
// 	}
// 	
// 
// }


import com.jayqqaa12.jbase.spring.serialize.RedisJsonSerializer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
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.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import java.net.UnknownHostException;
package com.jayqqaa12.jbase.spring.boot.config;



/**
 * Created by 12 on 2017/6/1.
 */
@Configuration
@ConditionalOnClass(RedisTemplate.class)
public class RedisConfig {


    @Bean
    public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) throws UnknownHostException {
        RedisTemplate template = new RedisTemplate<>();
        template.setConnectionFactory(redisConnectionFactory);
        template.setKeySerializer(new StringRedisSerializer());
// Path: jbase-spring/src/main/java/com/jayqqaa12/jbase/spring/serialize/RedisJsonSerializer.java
// public class RedisJsonSerializer<T> implements RedisSerializer<T> {
// 
// 
// 	private static final SerializerFeature[] features = {
// 			SerializerFeature.WriteEnumUsingToString,
// 			SerializerFeature.SortField, SerializerFeature.SkipTransientField,
// 			SerializerFeature.WriteClassName };
// 
// 	private static final Feature[] DEFAULT_PARSER_FEATURE = {
// 			Feature.AutoCloseSource, Feature.InternFieldNames,
// 			Feature.AllowUnQuotedFieldNames, Feature.AllowSingleQuotes,
// 			Feature.AllowArbitraryCommas, Feature.SortFeidFastMatch,
// 			Feature.IgnoreNotMatch };
// 
// 	@Override
// 	public byte[] serialize(Object t) throws SerializationException {
// 		return JSON.toJSONBytes(t, features);
// 	}
// 
// 	@SuppressWarnings("unchecked")
// 	@Override
// 	public T deserialize(byte[] bytes) throws SerializationException {
// 		if (bytes == null)
// 			return null;
// 		return (T) JSON.parse(bytes, DEFAULT_PARSER_FEATURE);
// 	}
// 	
// 
// }


// Path: jbase-spring/src/main/java/com/jayqqaa12/jbase/spring/boot/config/RedisConfig.java
import com.jayqqaa12.jbase.spring.serialize.RedisJsonSerializer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
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.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import java.net.UnknownHostException;

package com.jayqqaa12.jbase.spring.boot.config;



/**
 * Created by 12 on 2017/6/1.
 */
@Configuration
@ConditionalOnClass(RedisTemplate.class)
public class RedisConfig {


    @Bean
    public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) throws UnknownHostException {
        RedisTemplate template = new RedisTemplate<>();
        template.setConnectionFactory(redisConnectionFactory);
        template.setKeySerializer(new StringRedisSerializer());
        template.setDefaultSerializer(new RedisJsonSerializer<>());