【发布时间】:2020-08-31 18:23:33
【问题描述】:
(Will Spring's @CachePut annotation work with a void return type?)
我遇到了同样的问题
因为问题很久了,不知道有没有解决办法
创建了一个缓存:
public static final String Key = "CacheKey";
@Cacheable(cacheNames = "userCache", key = "Key")
public List<User> getAllUsers() {
...
}
使用@CachePut 更新此缓存
@CachePut(cacheNames = "userCache", key = "Key")
public User addUser(User user) {
...
}
输出:
com.example.demo.dto.UserDTO cannot be cast to java.util.List
找了几天资料,没有找到答案
除了使用@CacheEvict (cacheNames = userCache, allEntries = true)
有没有办法使用@Cacheable 和@CachePut 来解决它?
谢谢
【问题讨论】: