首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ehcache管理器

Ehcache管理器
EN

Stack Overflow用户
提问于 2013-03-18 18:27:22
回答 1查看 1.6K关注 0票数 0

我有一个使用JDBCTemplate和Hibernate的应用程序。

这两个配置都使用ehcache,但抛出了异常:

代码语言:javascript
复制
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中的默认缓存,但失败了,并且我将shared属性设置为true,这也导致了失败。

代码语言:javascript
复制
<?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>

在这种情况下如何提供唯一的名称?

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-03-25 09:54:45

创建两个具有不同名称的ehcache.xml配置。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15474545

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档