本文整理汇总了Java中org.springframework.data.redis.core.StringRedisTemplate.afterPropertiesSet方法的典型用法代码示例。如果您正苦于以下问题:Java StringRedisTemplate.afterPropertiesSet方法的具体用法?Java StringRedisTemplate.afterPropertiesSet怎么用?Java StringRedisTemplate.afterPropertiesSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.data.redis.core.StringRedisTemplate
的用法示例。
在下文中一共展示了StringRedisTemplate.afterPropertiesSet方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: RedisMessageChannelBinder
import org.springframework.data.redis.core.StringRedisTemplate; //导入方法依赖的package包/类
public RedisMessageChannelBinder(RedisConnectionFactory connectionFactory, String... headersToMap) {
Assert.notNull(connectionFactory, "connectionFactory must not be null");
this.connectionFactory = connectionFactory;
StringRedisTemplate template = new StringRedisTemplate(connectionFactory);
template.afterPropertiesSet();
this.redisOperations = template;
if (headersToMap != null && headersToMap.length > 0) {
String[] combinedHeadersToMap =
Arrays.copyOfRange(BinderHeaders.STANDARD_HEADERS, 0, BinderHeaders.STANDARD_HEADERS.length
+ headersToMap.length);
System.arraycopy(headersToMap, 0, combinedHeadersToMap, BinderHeaders.STANDARD_HEADERS.length,
headersToMap.length);
this.headersToMap = combinedHeadersToMap;
}
else {
this.headersToMap = BinderHeaders.STANDARD_HEADERS;
}
this.errorAdapter = new RedisQueueOutboundChannelAdapter(
parser.parseExpression("headers['" + ERROR_HEADER + "']"), connectionFactory);
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-redis,代码行数:21,代码来源:RedisMessageChannelBinder.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;
}
示例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: setUp
import org.springframework.data.redis.core.StringRedisTemplate; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
RedisConnectionFactory connectionFactory = TestRedis.connectionFactory();
dao.setConnectionFactory(connectionFactory);
dao.setNamespace("namespace");
dao.afterPropertiesSet();
redis = new StringRedisTemplate();
redis.setConnectionFactory(connectionFactory);
redis.afterPropertiesSet();
}
示例9: setUp
import org.springframework.data.redis.core.StringRedisTemplate; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
RedisConnectionFactory connectionFactory = TestRedis.connectionFactory();
dao.setConnectionFactory(connectionFactory);
dao.setNamespace("namespace");
dao.afterPropertiesSet();
redis = new StringRedisTemplate();
redis.setConnectionFactory(connectionFactory);
redis.afterPropertiesSet();
}
示例10: redisTemplate
import org.springframework.data.redis.core.StringRedisTemplate; //导入方法依赖的package包/类
@Bean
public RedisTemplate<String, String> redisTemplate(
RedisConnectionFactory factory) {
StringRedisTemplate template = new StringRedisTemplate(factory);
setSerializer(template); // 设置序列化工具,这样ReportBean不需要实现Serializable接口
template.afterPropertiesSet();
return template;
}
示例11: testDefaultPayloadSerializer
import org.springframework.data.redis.core.StringRedisTemplate; //导入方法依赖的package包/类
@Test
public void testDefaultPayloadSerializer() throws Exception {
StringRedisTemplate template = new StringRedisTemplate(connectionFactory);
template.afterPropertiesSet();
adapter.afterPropertiesSet();
adapter.handleMessage(new GenericMessage<String>("message1"));
assertEquals("message1", template.boundListOps(QUEUE_NAME).rightPop());
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-redis,代码行数:10,代码来源:RedisQueueOutboundChannelAdapterTests.java
示例12: 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;
}
示例13: createStringRedisTemplate
import org.springframework.data.redis.core.StringRedisTemplate; //导入方法依赖的package包/类
protected StringRedisTemplate createStringRedisTemplate(RedisConnectionFactory connectionFactory) {
StringRedisTemplate redisTemplate = new StringRedisTemplate();
redisTemplate.setConnectionFactory(connectionFactory);
redisTemplate.afterPropertiesSet();
return redisTemplate;
}