当我对所有条目使用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)
...https://stackoverflow.com/questions/44559899
复制相似问题