0

JDBCTemplate と Hibernate を使用するアプリケーションがあります。

これはどちらも ehcache を使用するように構成しますが、例外がスローされます。

org.hibernate.cache.CacheException: net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following:

spring xml を使用して構成された JDBCTemplate hibernate.cfg.xml を使用して構成された Hibernate

助けてください。

ehcache.xml でデフォルトのキャッシュを無効にしようとしましたが、失敗し、共有プロパティが true に設定されているため、これも失敗しました。

<?xml version="1.0" encoding="UTF-8"?>

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

    <diskStore path="java.io.tmpdir" />

    <!--<defaultCache eternal="true" maxElementsInMemory="50000"
        overflowToDisk="false" diskPersistent="false" timeToIdleSeconds="0"
        timeToLiveSeconds="0" memoryStoreEvictionPolicy="LRU" 
        />
    -->

    <cache name="genericDao" eternal="false" maxElementsInMemory="50000"
        overflowToDisk="false" memoryStoreEvictionPolicy="LFU" />

    <cache name="reportDao" eternal="false" maxElementsInMemory="50000"
        timeToIdleSeconds="28800" timeToLiveSeconds="28800"
        overflowToDisk="false" memoryStoreEvictionPolicy="LFU" />


 </ehcache>

<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"> 
        <property name="configLocation" value="WEB-INF/ehcache/ehcache.xml"></property>
        <property name="shared" value="true"></property>
    </bean>

    <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
        <property name="cacheManager" ref="ehcache"></property>
    </bean>

この場合、一意の名前を指定するにはどうすればよいですか?

ありがとう。

4

1 に答える 1

1

異なる名前で 2 つの ehcache.xml 構成を作成します。

于 2013-03-25T01:54:45.113 に答える