项目里使用了ehcache作为二级缓存版本是ehcache-core-2.4.6.jar,hibernate3。之前在开发环境时启用了二级缓存,开发调试均一切正常,但是换了个环境重新发布并部署到Tomcat,就报[color=red]Invocation of init method failed; nested exception is org.hibernate.cache.NoCachingEnabledException: Second-level cache is not enabled for usage [hibernate.cache.use_second_level_cache | hibernate.cache.use_query_cache][/color]
谁能帮我解决一下。
配置如下:
使用spring对hibernate进行管理
[code="xml"]
true
true
net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory
[/code]
*.hbm.xml
[code="xml"]
[/code]
ehcache.xml里有对应的缓存配置,在DAO里启用查询缓存
q.setCacheable(true);
q.setCacheRegion("com.longteng.tables.XXXX");