@Override
@Cacheable(cacheManager = "redis1DayCacheManager", cacheNames = "reserve", key = "#userId", unless = "#result == null")
public boolean hasReserve(Integer userId) {
...
}
如上代码会报错
java.lang.IllegalArgumentException: Null key returned for cache operation (maybe you are using named params on classes without debug info?)
在网上找解决办法,有些说把参数改成p0或a0,我试了都不行;
最后在注解里加了个条件condition,成功
@Override
@Cacheable(cacheManager = "redis1DayCacheManager", cacheNames = "reserve", key = "#userId", condition = "#userId!=null", unless = "#result == null")
public boolean hasReserve(Integer userId) {
...
}