max*_*dev 10 java spring spring-data-redis
当我尝试从Spring Data Redis注入实现CrudRepository的存储库时,我得到NoSuchBeanDefinitionException.
引起:org.springframework.beans.factory.NoSuchBeanDefinitionException:找不到类型为[bluh.bluh.repository.XxxRepository]的限定bean依赖:预期至少有1个bean符合此依赖关系的autowire候选者.依赖注释:{@ org.springframework.beans.factory.annotation.Autowired(required = true)}
但是配置在那里,它用@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;
}
}
Run Code Online (Sandbox Code Playgroud)
存储库界面如下所示:
import org.springframework.data.repository.CrudRepository;
public interface XxxRepository extends CrudRepository<String, String> { }
Run Code Online (Sandbox Code Playgroud)
我经历过http://docs.spring.io/spring-data/redis/docs/current/reference/html/,对我来说没什么新鲜的.我想知道我错过了什么,我会感激任何投入.
我使用Spring Data Redis 1.7.2.RELEASE,Spring Boot 1.3.6.RELEASE
小智 2
有点晚了,但对于其他遇到此问题的人来说:
我只是坐在那里拉着我的头发。下载了 GIT 示例并注意到该实体用 @RedisHash("hash_name_here") 进行了注释:
@RedisHash("MyDataThingies")
public class MyDataThingy{
@Id
public String id
}
Run Code Online (Sandbox Code Playgroud)
现在它有连接问题,但我知道为什么:)