本文介绍了Ehcache关闭在运行测试套件时导致异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到以下问题.
我的项目中有一个测试服,每个测试都运行良好.
I have a test suit in my project and each individual test runs fine.
但是,当我将它们作为套件运行时,它们中的一些由于以下异常而失败:
However when I run them as a suite I some of them fails with the following exception:
Caused by: java.lang.IllegalStateException: The dao Cache is not alive (STATUS_SHUTDOWN)
at net.sf.ehcache.Cache$CacheStatus.checkAlive(Cache.java:4269)
at net.sf.ehcache.Cache.checkStatus(Cache.java:2703)
at net.sf.ehcache.Cache.get(Cache.java:1576)
at org.springframework.cache.ehcache.EhCacheCache.get(EhCacheCache.java:61)
at org.springframework.cache.interceptor.CacheAspectSupport.inspectCacheables(CacheAspectSupport.java:310)
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:198)
at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:66)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
是否有一种方法可以避免这种行为,即在多个测试中保持高速缓存活动或正确关闭高速缓存?
Is there a way to avoid this behavior, i.e. keep the cache alive across multiple test or shutting it down properly?
推荐答案
尝试在测试上下文中的EhCacheManagerFactoryBean
或EhCacheCacheManager
中将共享属性设置为false.
try to set shared property to false in EhCacheManagerFactoryBean
or EhCacheCacheManager
in the testing context.
这篇关于Ehcache关闭在运行测试套件时导致异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!