本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}