當前位置: 首頁>>代碼示例>>Java>>正文


Java StringRedisTemplate.setValueSerializer方法代碼示例

本文整理匯總了Java中org.springframework.data.redis.core.StringRedisTemplate.setValueSerializer方法的典型用法代碼示例。如果您正苦於以下問題:Java StringRedisTemplate.setValueSerializer方法的具體用法?Java StringRedisTemplate.setValueSerializer怎麽用?Java StringRedisTemplate.setValueSerializer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.data.redis.core.StringRedisTemplate的用法示例。


在下文中一共展示了StringRedisTemplate.setValueSerializer方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: redisTemplate

import org.springframework.data.redis.core.StringRedisTemplate; //導入方法依賴的package包/類
/**
 * RedisTemplate配置
 * @param factory
 * @return
 */
@Bean
@SuppressWarnings({"rawtypes", "unchecked"})
public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) {
    StringRedisTemplate template = new StringRedisTemplate(factory);
    //定義value的序列化方式
    Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
    ObjectMapper om = new ObjectMapper();
    om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
    om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
    jackson2JsonRedisSerializer.setObjectMapper(om);
    
    template.setValueSerializer(jackson2JsonRedisSerializer);
    template.setHashValueSerializer(jackson2JsonRedisSerializer);
    template.afterPropertiesSet();
    return template;
}
 
開發者ID:SnailFastGo,項目名稱:springboot_op,代碼行數:22,代碼來源:RedisConfiguration.java

示例2: redisTemplate

import org.springframework.data.redis.core.StringRedisTemplate; //導入方法依賴的package包/類
@Bean("redisTemplate")  //新家的這個注解 10-26 12:06
@SuppressWarnings({ "rawtypes", "unchecked" })
public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory redisFactory){
	StringRedisTemplate template = new StringRedisTemplate(redisFactory);
	Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new 
			Jackson2JsonRedisSerializer(Object.class);
	
	ObjectMapper om = new ObjectMapper();
	om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
	om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
	jackson2JsonRedisSerializer.setObjectMapper(om);
	
	template.setValueSerializer(jackson2JsonRedisSerializer);
	template.afterPropertiesSet();
	return template;
}
 
開發者ID:duanyaxin,項目名稱:springboot-smart,代碼行數:17,代碼來源:RedisConfiguration.java

示例3: getStringRedisTemplate

import org.springframework.data.redis.core.StringRedisTemplate; //導入方法依賴的package包/類
@Bean
public RedisTemplate getStringRedisTemplate() {
    StringRedisTemplate clusterTemplate = new StringRedisTemplate();
    clusterTemplate.setConnectionFactory(jedisConnectionFactory());
    clusterTemplate.setKeySerializer(new StringRedisSerializer());
    clusterTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer());
    return clusterTemplate;
}
 
開發者ID:yu199195,項目名稱:happylifeplat-transaction,代碼行數:9,代碼來源:RedisClusterConfig.java

示例4: redisTemplate

import org.springframework.data.redis.core.StringRedisTemplate; //導入方法依賴的package包/類
@SuppressWarnings({"unchecked","rawtypes"})
@Bean  
   public RedisTemplate<String, String> redisTemplate(  
           RedisConnectionFactory factory) {  
       StringRedisTemplate template = new StringRedisTemplate(factory);  
	Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);  
       ObjectMapper om = new ObjectMapper();  
       om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);  
       om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);  
       jackson2JsonRedisSerializer.setObjectMapper(om);  
       template.setValueSerializer(jackson2JsonRedisSerializer);  
       template.afterPropertiesSet();  
       return template;  
   }
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:15,代碼來源:RedisConfig.java

示例5: redisTemplate

import org.springframework.data.redis.core.StringRedisTemplate; //導入方法依賴的package包/類
@Bean
public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) {
    StringRedisTemplate template = new StringRedisTemplate(factory);
    Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
    ObjectMapper om = new ObjectMapper();
    om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
    om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
    jackson2JsonRedisSerializer.setObjectMapper(om);
    template.setValueSerializer(jackson2JsonRedisSerializer);
    template.afterPropertiesSet();
    return template;
}
 
開發者ID:ChinaLHR,項目名稱:JavaQuarkBBS,代碼行數:13,代碼來源:RedisConfig.java

示例6: redisTemplate

import org.springframework.data.redis.core.StringRedisTemplate; //導入方法依賴的package包/類
@Bean
@SuppressWarnings({ "rawtypes", "unchecked" })
public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) {
	StringRedisTemplate template = new StringRedisTemplate(factory);
	Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
	ObjectMapper om = new ObjectMapper();
	om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
	om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
	jackson2JsonRedisSerializer.setObjectMapper(om);
	template.setValueSerializer(jackson2JsonRedisSerializer);
	template.afterPropertiesSet();
	return template;
}
 
開發者ID:lemon-china,項目名稱:lemon-dubbo-message,代碼行數:14,代碼來源:RedisConfiguration.java

示例7: afterPropertiesSet

import org.springframework.data.redis.core.StringRedisTemplate; //導入方法依賴的package包/類
@Override
public void afterPropertiesSet() throws Exception {
    templates = new ArrayList<RedisTemplate>();
    List<JedisConnectionFactory> factorys = connectionFactory.getFactories();
    for (JedisConnectionFactory factory : factorys) {
        StringRedisTemplate template = new StringRedisTemplate(factory);
        template.setKeySerializer(keySerializer);
        template.setValueSerializer(valueSerializer);
        template.setHashKeySerializer(hashKeySerializer);
        template.setHashValueSerializer(hashValueSerializer);
        // 執行必要方法
        template.afterPropertiesSet();
        templates.add(template);
    }
}
 
開發者ID:Fourwenwen,項目名稱:consistent-hashing-redis,代碼行數:16,代碼來源:HwRedisTemplate.java

示例8: setSerializer

import org.springframework.data.redis.core.StringRedisTemplate; //導入方法依賴的package包/類
private void setSerializer(StringRedisTemplate template) {
	Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(
			Object.class);
	ObjectMapper om = new ObjectMapper();
	om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
	om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
	jackson2JsonRedisSerializer.setObjectMapper(om);
	template.setValueSerializer(jackson2JsonRedisSerializer);
}
 
開發者ID:Myazure,項目名稱:weixin_component,代碼行數:10,代碼來源:RedisConfiguration.java

示例9: redisTemplate

import org.springframework.data.redis.core.StringRedisTemplate; //導入方法依賴的package包/類
@Bean
public RedisTemplate<String, String> redisTemplate(
        RedisConnectionFactory redisConnectionFactory) {
    logger.info("init redis template...");
    StringRedisTemplate template = new StringRedisTemplate(redisConnectionFactory);
    Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
    ObjectMapper om = new ObjectMapper();
    om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
    om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
    jackson2JsonRedisSerializer.setObjectMapper(om);
    template.setValueSerializer(jackson2JsonRedisSerializer);
    template.afterPropertiesSet();
    return template;
}
 
開發者ID:fireshort,項目名稱:spring-boot-quickstart,代碼行數:15,代碼來源:RedisConfig.java


注:本文中的org.springframework.data.redis.core.StringRedisTemplate.setValueSerializer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。