Другой безымянный CacheManager уже существует в той же виртуальной машине (ehCache 2.5)

Вот что происходит, когда я запускаю тесты junit...

Another CacheManager with same name 'cacheManager' already exists in the same VM. Please 
provide unique names for each CacheManager in the config or do one of following:
1. Use one of the CacheManager.create() static factory methods to reuse same
   CacheManager with same name or create one if necessary
2. Shutdown the earlier cacheManager before creating new one with same name.

The source of the existing CacheManager is: 
 DefaultConfigurationSource [ ehcache.xml or ehcache-failsafe.xml ]

В чем причина исключения. Может ли одновременно работать более 1 cacheManager?

Вот как я настроил cachManager с помощью Sping 3.1.1. Он явно устанавливает область действия cacheManager как "singleton"

<ehcache:annotation-driven />

<bean
    id="cacheManager"
    class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
    scope="singleton"
    />

ehcache.xml выглядит так

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
     updateCheck="false"
     maxBytesLocalHeap="100M" 
     name="cacheManager"
     >
 ....
 </ehcache>

Наконец, мой класс

@Component
public class BookingCache implements CacheWrapper<String, BookingUIBean> {

     @Autowired
     private CacheManager ehCacheManager;
      ....
}

Я совершенно уверен, что имею дело только с одним cacheManager в своей кодовой базе. Что-то еще, вероятно, запускает n-й экземпляр.

73
задан slim 3 May 2016 в 12:36
поделиться