作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我最近将 simple-spring-memcached 从版本 3.6.1 升级到了 4.1.1。但是,在此版本升级之后,每当我的代码尝试从缓存中获取值时,我都会收到 WrappedCacheException。我在下面分享我的代码片段:
@Transactional
@Cacheable(value = CACHE_NAME, key = "#id")
@Override
public TicketModel validate(final String id) {
TicketEntity ticketEntity = ticketEntityRepository.findOne(id);
if (ticketEntity == null) {
System.out.println("Ticket not found")
}
return something;
}
我的cacheManager bean看起来像:
@Bean
public CacheManager cacheManager() throws Exception {
List<SSMCache> cacheList = new ArrayList<>();
CacheFactory cacheFactory;
if (ELASTIC_CACHE_FACTORY.equals(cacheBean)) {
cacheFactory = elastiCacheFactory();
} else {
cacheFactory = memCacheFactory();
}
Cache cache = cacheFactory.getObject();
SSMCache aamCache = new SSMCache(cache, cacheTimeout, true);
cacheList.add(aamCache);
SSMCacheManager cacheManager = new SSMCacheManager();
cacheManager.setCaches(cacheList);
cacheManager.afterPropertiesSet();
return cacheManager;
}
我得到的确切异常如下所示:
SEVERE: Servlet.service() for servlet [jersey-servlet] in context with path [/user-service-web] threw exception [com.google.code.ssm.spring.WrappedCacheException] with root cause
com.google.code.ssm.spring.WrappedCacheException
at com.google.code.ssm.spring.SSMCache.logOrThrow(SSMCache.java:318)
at com.google.code.ssm.spring.SSMCache.getValue(SSMCache.java:285)
at com.google.code.ssm.spring.SSMCache.get(SSMCache.java:117)
at org.springframework.cache.interceptor.AbstractCacheInvoker.doGet(AbstractCacheInvoker.java:68)
at org.springframework.cache.interceptor.CacheAspectSupport.findInCaches(CacheAspectSupport.java:469)
at org.springframework.cache.interceptor.CacheAspectSupport.findCachedItem(CacheAspectSupport.java:435)
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:336)
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:302)
at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
每当调用 findOne(id) 方法时,我都会收到 WrappedCacheException 并且代码失败。请帮忙。
最佳答案
在 4.0.0 之前,从底层缓存/客户端层抛出的异常(例如 IOException 等)被 SsmCache 对象吞噬。 4.0.0 之后,默认情况下,这些会被抛出给调用者。您可以通过将 SsmCache bean 上的“muteExceptions”标志设置为 true 来恢复之前的行为。
关于java - simple-spring-memcached 升级到 4.1.1 导致 WrappedCacheException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53406810/
我最近将 simple-spring-memcached 从版本 3.6.1 升级到了 4.1.1。但是,在此版本升级之后,每当我的代码尝试从缓存中获取值时,我都会收到 WrappedCacheExc
我是一名优秀的程序员,十分优秀!