无法使用Redis和Spring找到默认的ScheduledExecutorService bean

时间:2015-06-29 13:54:02

标签: spring redis spring-session

我刚刚使用Spring Session和Redis开发配置,一切正常,但在我的控制台日志中,我得到了

 2015-06-29 15:45:44,088 [main] DEBUG org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor -     Could not find default ScheduledExecutorService bean
 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.scheduling.TaskScheduler] is defined

如何配置ScheduledExecutorService bean?

更新:

   @Configuration
   @EnableRedisHttpSession
   @Conditional(RedisDeclarationCondition.class)
   public class LocalRedisConfig extends WebMVCConfig{


       @Value("${redis.host}")
       private String host;

       @Value("${redis.port}")
       private String port;

       @Bean
       public JedisConnectionFactory connectionFactory() {
         return new JedisConnectionFactory();
       }


@Bean
public RedisConnectionFactory jedisConnectionFactory(){
    JedisPoolConfig poolConfig = new JedisPoolConfig();
    poolConfig.setMaxIdle(5);
    poolConfig.setMaxTotal(10);
    poolConfig.setMinIdle(1);
    poolConfig.setTestOnBorrow(true);
    poolConfig.setTestOnReturn(true);
    poolConfig.setTestWhileIdle(true);
    JedisConnectionFactory jedisConnectionFactory = new                 JedisConnectionFactory(poolConfig);
  //        RedisOperationsSessionRepository cleanup = new RedisOperationsSessionRepository(jedisConnectionFactory);

        //optional 
        //jedisConnectionFactory.setHostName(host);
        //jedisConnectionFactory.setPort(Integer.valueOf(port));

        return jedisConnectionFactory;
}

@Bean
public StringRedisTemplate redisTemplate(){
    StringRedisTemplate redisTemplate = new StringRedisTemplate(jedisConnectionFactory());
    return redisTemplate;
}

1 个答案:

答案 0 :(得分:-1)

这是一个DEBUG消息,可以通过设置您的logging.level.org.springframework = INFO

来忽略

Using @Scheduled and @EnableScheduling but gives NoSuchBeanDefinitionException