Could not find configuration [org.hibernate.cache.UpdateTimestampsCache]; using defaults
2012-11-02 18:46
260 查看
No configuration found. Configuring ehcache from ehcache-failsafe.xml 。ehcache-failsafe.xml 是来自于ehcache-1.1.jar包,但原因并不是找不到 ehcache-failsafe.xml 而造成的错误,把 ehcache-1.1.jar包里的 ehcache-failsafe.xml 抽取出来,改名为ehcache.xml放到工程的Src目录下,刷新一下并运行,OK,没有警告了!
一般伴随这个的,还有下面两个警告:
Could not find configuration [org.hibernate.cache.UpdateTimestampsCache]; using defaults.
Could not find configuration [org.hibernate.cache.StandardQueryCache]; using defaults.
原因就是你配置了spring二级缓存不完全造成的
参见下面的文章:
1.首先,在spring的hibernate配置里(我的是applicationContext-hibernate.xml) 加上如下属性:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="mappingResources">
<list>
<value>org/appfteaching/model/TArticleclass.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop>
<prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
</props>
</property>
</bean>
2.其次,在src目录下的ehcache.xml中配置如下信息(如果是默认ehcache.xml则会有<cache name="sampleCache1">和<cache name="sampleCache2>",去掉)
<cache name="org.hibernate.cache.StandardQueryCache"
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="4200"
overflowToDisk="true"
/>
<!-- Sample cache named sampleCache2
This cache contains 1000 elements. Elements will always be held in memory.
They are not expired. -->
<cache name="org.hibernate.cache.UpdateTimestampsCache"
maxElementsInMemory="5000"
eternal="true"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
overflowToDisk="false"
/>
3.将你要缓存的model加进ehcache.xml里
<cache name="org.appfteaching.model.TArticleclass"
maxElementsInMemory="1000"
eternal="false"
timeToIdleSeconds="100"
timeToLiveSeconds="4200"
overflowToDisk="true"
/>
一般伴随这个的,还有下面两个警告:
Could not find configuration [org.hibernate.cache.UpdateTimestampsCache]; using defaults.
Could not find configuration [org.hibernate.cache.StandardQueryCache]; using defaults.
原因就是你配置了spring二级缓存不完全造成的
参见下面的文章:
1.首先,在spring的hibernate配置里(我的是applicationContext-hibernate.xml) 加上如下属性:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="mappingResources">
<list>
<value>org/appfteaching/model/TArticleclass.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop>
<prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
</props>
</property>
</bean>
2.其次,在src目录下的ehcache.xml中配置如下信息(如果是默认ehcache.xml则会有<cache name="sampleCache1">和<cache name="sampleCache2>",去掉)
<cache name="org.hibernate.cache.StandardQueryCache"
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="4200"
overflowToDisk="true"
/>
<!-- Sample cache named sampleCache2
This cache contains 1000 elements. Elements will always be held in memory.
They are not expired. -->
<cache name="org.hibernate.cache.UpdateTimestampsCache"
maxElementsInMemory="5000"
eternal="true"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
overflowToDisk="false"
/>
3.将你要缓存的model加进ehcache.xml里
<cache name="org.appfteaching.model.TArticleclass"
maxElementsInMemory="1000"
eternal="false"
timeToIdleSeconds="100"
timeToLiveSeconds="4200"
overflowToDisk="true"
/>
相关文章推荐
- Could not find configuration [org.hibernate.cache.UpdateTimestampsCache]; using defaults
- [Java web]Could not find configuration [org.hibernate.cache.UpdateTimestampsCache]; using defaults
- Could not instantiate bean class [org.hibernate.cfg.Configuration]: Construct
- EntityManager的find()与getReference()的区别(org.hibernate.lazyinitializationexception could not initialize proxy no session)
- org.hibernate.PropertyNotFoundException: Could not find a getter
- 解决:ould not find a getter for porDate in class com.bc.bean.PortalSheet Caused by: org.hibernate.PropertyNotFoundException: Could
- org.hibernate.PropertyNotFoundException: Could not find a getter for empDeptId in class
- org.hibernate.PropertyNotFoundException: Could not find a getter for
- " org.hibernate.PropertyNotFoundException:Could not find a getter for ..
- SSH配置启动后Tomcat后报错:Could not instantiate bean class [org.hibernate.cfg.Configuration]
- org.hibernate.HibernateException: Could not find datasource
- could not instantiate RegionFactory [org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBrid
- could not instantiate RegionFactory [org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridg
- nested exception is org.hibernate.PropertyNotFoundException: Could not find a getter for eNum in class
- java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.cfg.AnnotationConfiguration
- org.hibernate.PropertyNotFoundException:could not find a getter for name in class ....
- org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.impl.brid
- org.hibernate.PropertyNotFoundException Could not find a getter for id in class
- hibernate出现:org.hibernate.PropertyNotFoundException: Could not find a getter for id in class
- 异常:org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml