Ehcache shutdown causing an exception while running test suite

前端 未结 4 948
春和景丽
春和景丽 2021-01-01 16:55

I\'m experiencing the following problem.

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 th

4条回答
  •  既然无缘
    2021-01-01 17:53

    Make a seperate cache config for tests only! and put scope "prototype"

    @Configuration
    @EnableCaching
    public class EhCacheConfig {
    
     @Bean(name = "cacheManager")
     @Scope("prototype")
     public CacheManager getCacheManager() {
        return new EhCacheCacheManager(getEhCacheFactory().getObject());
     }
    
     @Bean
     @Scope("prototype")
     public EhCacheManagerFactoryBean getEhCacheFactory() {
        EhCacheManagerFactoryBean factoryBean = new EhCacheManagerFactoryBean();
        factoryBean.setConfigLocation(new ClassPathResource("ehcache.xml"));
        factoryBean.setShared(true);
        return factoryBean;
     }
    }
    

提交回复
热议问题