【发布时间】:2017-06-15 06:14:27
【问题描述】:
当我对所有条目使用 CacheEvict 时,一切正常:
@CacheEvict(value = "users", allEntries = true)
但是当我想使用 key 来删除给定的缓存条目时,它只是找不到 key 并抛出 NullPointerException。我确定我传递了一个非空值作为参数。
@CacheEvict(value = "users", key = "#username")
void edit(String username, @Param(value = "user") User user);
java.lang.NullPointerException: null
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:782)
at com.google.common.cache.LocalCache$LocalManualCache.invalidate(LocalCache.java:5080)
at org.springframework.cache.guava.GuavaCache.evict(GuavaCache.java:139)
at org.springframework.cache.interceptor.AbstractCacheInvoker.doEvict(AbstractCacheInvoker.java:98)
at org.springframework.cache.interceptor.CacheAspectSupport.performCacheEvict(CacheAspectSupport.java:480)
at org.springframework.cache.interceptor.CacheAspectSupport.processCacheEvicts(CacheAspectSupport.java:463)
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:421)
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:327)
at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61)
...
【问题讨论】:
标签: spring caching spring-boot guava