“服务”中的字段redisRepository需要找不到“ repositpry”类型的Bean

时间:2019-01-11 05:52:11

标签: spring-boot redis

org.test.service.ResidService

@Slf4j
@Service
public class RedisService {
    private final RedisRepository redisRepository;

    public RedisService(final RedisRepository redisRepository) {
        this.redisRepository = redisRepository;
    }

    public List<Token> getAllRedisToken() {
        String token = "...";
        Map<byte[], byte[]> aa = redisRepository.hGetAll(token.getBytes());
        log.info(aa.toString());
        return null;
    }
}

org.test.repository.RedisRepository

@SpringBootApplication
@Service
public interface RedisRepository extends RedisHashCommands {}

尝试执行代码时出错。

Description:

Field redisRepository in org.test.service.ResidService required a bean of type 'org.smilegate.repository.RedisRepository' that could not be found.


Action:

Consider defining a bean of type 'org.test.repository.RedisRepository' in your configuration.

我搜索了错误,并尝试了所有解决方案。 我尝试在RedisRepository中添加@Serice / @Component / @SpringBootApplication RedisService中的@retorepository中的@Qutowired

但是,无论您如何尝试,错误都无法解决。 我想通过RedisHashCommands连接Redis。

如何通过“ RedisHashCommands”从“ spring boot”获得值? 请帮助...请;)

0 个答案:

没有答案