未加载“ RedisReactiveAutoConfiguration”中的“ reactiveRedisTemplate”

时间:2019-09-10 06:45:51

标签: redis reactive

我无法在测试中创建对象 课

我 尝试使用 自动装配和模拟注释

@RunWith(SpringRunner.class)

@SpringBootTest
public class RedisApplicationTests {

        @Mock
        RedisValueRepository<Object, Object> valueRepository;

        @Test
        public void putUsingValue() {

            this.valueRepository.putUsingValue("123", new Employee(123, "Bill", "Accounts"));
            System.out.println("saving the Employees ");

        }
    }

    @Repository
    public class RedisValueRepository<K, HV> implements ValueCaching<K, HV> {
        private ReactiveValueOperations<K, HV> hashOperations;

        @Autowired
        private ReactiveRedisTemplate<K, HV> redisTemplate;

        public RedisValueRepository(ReactiveRedisTemplate<K, HV> reactiveRedisTemplate) {
            this.redisTemplate = reactiveRedisTemplate;
            this.hashOperations = this.redisTemplate.opsForValue();
        }

    @Override
    public Mono<HV> getUsingValue(@NonNull K key) {
        log.trace("START: Retrieve value using key [{}] and hashkey [{}]", key, key);
        Mono<HV> value = hashOperations.get(key);
        log.trace("END: Retrieve value using key [{}] and hashkey [{}]", key, key);

        return value;
    }

0 个答案:

没有答案