当前位置: 首页>>代码示例>>Java>>正文


Java StringRedisTemplate.afterPropertiesSet方法代码示例

本文整理汇总了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;
}
 
开发者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: 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;  
   }
 
开发者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: 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();
}
 
开发者ID:shopping24,项目名称:redjob,代码行数:13,代码来源:LockDaoImplIT.java

示例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();
}
 
开发者ID:shopping24,项目名称:redjob,代码行数:12,代码来源:WorkerDaoImplIT.java

示例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;
}
 
开发者ID:Myazure,项目名称:weixin_component,代码行数:9,代码来源:RedisConfiguration.java

示例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;
}
 
开发者ID:fireshort,项目名称:spring-boot-quickstart,代码行数:15,代码来源:RedisConfig.java

示例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;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:7,代码来源:RedisSinkApplicationTests.java


注:本文中的org.springframework.data.redis.core.StringRedisTemplate.afterPropertiesSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。