title: Spring Data Redis
body: <p>I'm using spring data redis and jedis with aspectJ for logging.
  But getting the below error. Please help in resolving this error. I have spent lot of time on this but couldn't resolve it.</p>
  
  <p>I'm using spring data redis 1.4.1, jedis-2.6.1 with Redis-2.8</p>
  
  <p>Error Details:-</p>
  
  <pre><code>Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Illegal arguments to factory method [public org.springframework.data.redis.core.RedisTemplate com.test.RedisSentinelApplicationConfig.redisTemplate()]; args: 
      at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:172)
      at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:586)
      ... 38 more
  </code></pre>
  
  <p>Below is the Java configuration file for the redis Sentinel configuration using spring data redis</p>
  
  <pre><code>@Configuration
  public class RedisSentinelApplicationConfig {   
      private static final Logger logger = LoggerFactory.getLogger(RedisSentinelApplicationConfig.class);
  
      @Autowired
      private Environment env;
  
      @Value("${redis.master}") 
      private String REDIS_MASTER;
  
      public RedisSentinelConfiguration redisSentinelConfiguration() {
          if(null != env){
              logger.debug("env--&gt;" + env.getProperty("redis.master"));
          }else{
              logger.debug("ENV object is null");
          }
  
          logger.debug("REDIS_MASTER--&gt;" + REDIS_MASTER);
  
          final RedisSentinelConfiguration SENTINEL_CONFIG = new RedisSentinelConfiguration()
          .master(env.getProperty("redis.master"))
          .sentinel(env.getProperty("redis.sentinel1.host"), Integer.valueOf(env.getProperty("redis.sentinel1.port")))
          .sentinel(env.getProperty("redis.sentinel2.host"), Integer.valueOf(env.getProperty("redis.sentinel2.port")))
          .sentinel(env.getProperty("redis.sentinel3.host"), Integer.valueOf(env.getProperty("redis.sentinel3.port")));
  
          return SENTINEL_CONFIG;
      }
  
      @Bean
      public RedisConnectionFactory jedisConnectionFactory() {
          return new JedisConnectionFactory(sentinelConfig());
      }
  
      @Bean
      public RedisSentinelConfiguration sentinelConfig() {
          return redisSentinelConfiguration();
      }
  
      @Bean
      public RedisTemplate&lt;String, ?&gt; redisTemplate() {
         RedisTemplate&lt;String, ?&gt; template = new RedisTemplate();
         template.setConnectionFactory(jedisConnectionFactory());
         template.setValueSerializer(jackson2JsonRedisSerializer());      
         template.setHashValueSerializer(jackson2JsonRedisSerializer());
          return template;
      }
  
      @SuppressWarnings("rawtypes")
      @Bean(name="cacheService")
      public CacheService CacheService() {
          return new CacheServiceImpl();
      }
  
      @Bean
      public Jackson2JsonRedisSerializer&lt;Object&gt; jackson2JsonRedisSerializer() {
          Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(
                  Object.class);
          jackson2JsonRedisSerializer.setObjectMapper(objectMapper());
          return jackson2JsonRedisSerializer;
      }
  
       @Bean
      public ObjectMapper objectMapper() {
          ObjectMapper objectMapper = new ObjectMapper();
          objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
          objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
          return objectMapper;
      }
  }
  </code></pre>
  
  <p>Below is the Aspectj configuration for the logging. If I comment the @Component, apart from logging everything works perfectly fine
  but the same doesn't work if @Component exist. It looks like AspectJ is conflicting with spring data redis</p>
  
  <pre><code>@Component
  @Aspect
  public class PerfApplicationLogger {
      private static final Logger log = LoggerFactory.getLogger(PerfApplicationLogger.class); 
  
      @Around("execution(* *(..))")
      public Object logTimeMethod(ProceedingJoinPoint joinPoint) throws Throwable {
  
              StopWatch stopWatch = new StopWatch();
              stopWatch.start();
  
              Object retVal = joinPoint.proceed();
  
              stopWatch.stop();
  
              StringBuilder logMessage = new StringBuilder();
              logMessage.append(joinPoint.getTarget().getClass().getName());
              logMessage.append(".");
              logMessage.append(joinPoint.getSignature().getName());
              logMessage.append("(");
              // append args
              Object[] args = joinPoint.getArgs();
              for (int i = 0; i &lt; args.length; i++) {
                  logMessage.append(args[i]).append(",");
              }
              if (args.length &gt; 0) {
                  logMessage.deleteCharAt(logMessage.length() - 1);
              }
  
              logMessage.append(")");
              logMessage.append(" execution time: ");
              logMessage.append(stopWatch.getTotalTimeMillis());
              logMessage.append(" ms");
              log.debug(logMessage.toString());
              return retVal;
      }
  }
  </code></pre>