Spring Data Redis NoSuchBeanDefinitionException: No qualifying bean of type

max_dev picture max_dev · Jul 14, 2016 · Viewed 7.9k times · Source

When I try to inject repository that implements CrudRepository from Spring Data Redis, I get NoSuchBeanDefinitionException.

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [bluh.bluh.repository.XxxRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

However configuration is there, it's annotated with @EnableRedisRepositories("bluh.bluh.repository")

@Configuration
@EnableRedisRepositories
public class ApplicationConfig {

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

    @Bean
    RedisTemplate<?, ?> redisTemplate(RedisConnectionFactory connectionFactory) {

        RedisTemplate<byte[], byte[]> template = new RedisTemplate<>();
        template.setConnectionFactory(connectionFactory);

        return template;
    }

}

Repository interface looks like:

import org.springframework.data.repository.CrudRepository;

public interface XxxRepository extends CrudRepository<String, String> { }

I've been through http://docs.spring.io/spring-data/redis/docs/current/reference/html/ , there's nothing new for me. I wonder what did I miss and I'll appreciate any inputs.

I use Spring Data Redis 1.7.2.RELEASE, Spring Boot 1.3.6.RELEASE

Answer

RabidDog5150 picture RabidDog5150 · Oct 3, 2016

Bit late but for anyone else having this issue:

I just sat pulling my hair out with this. Downloaded the GIT examples and noticed the entity was annotated with @RedisHash("hash_name_here"):

@RedisHash("MyDataThingies")
public class MyDataThingy{
    @Id
    public String id
}

Now it has connection issues but I know why :)