先看一个示例文件
<?xml version="1.0" encoding="UTF-8"?> <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"> <!-- maxElementsInMemory为缓存对象的最大数目, eternal设置是否永远不过期 timeToIdleSeconds对象处于空闲状态的最多秒数 timeToLiveSeconds对象处于缓存状态的最多秒数 --> <diskStore path="java.io.tmpdir" /> <defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="300" timeToLiveSeconds="600" overflowToDisk="true" /> <cache name="org.hibernate.cache.StandardQueryCache" maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="300" timeToLiveSeconds="4200" overflowToDisk="true" /> <cache name="org.hibernate.cache.UpdateTimestampsCache" maxElementsInMemory="5000" eternal="true" timeToIdleSeconds="0" timeToLiveSeconds="0" overflowToDisk="false" /> <cache name="tao.hib.bean.User" maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="10000" timeToLiveSeconds="10000" overflowToDisk="true" /> </ehcache>
如果 ehcache.xml 文件不存在: 在加载cfg文件的时候将抛出如下WRAN
WARN ConfigurationFactory:127 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/D:/Java/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me201003101716/myeclipse-data/3.2/lib/ehcache-1.2.3.jar!/ehcache-failsafe.xml
============================================================
如果 再 cfg 文件中配置了
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
但是在chcache.xml 文件中没有配置
<cache name="org.hibernate.cache.UpdateTimestampsCache"
<cache name="org.hibernate.cache.StandardQueryCache"
将会抛出如下wran:
23:06:33,468 WARN EhCacheProvider:93 - Could not find configuration [org.hibernate.cache.UpdateTimestampsCache]; using defaults.
23:06:33,468 WARN EhCacheProvider:93 - Could not find configuration [org.hibernate.cache.StandardQueryCache]; using defaults.
===============================
如果再 hbm.xml 中配置了 <cache usage="read-write"/>
而在cache中没有配置相关的mudol缓存
例如: <cache name="tao.hib.bean.User"
则会跑出如下 wran
WARN EhCacheProvider:93 - Could not find configuration [tao.hib.bean.User]; using defaults.