2
回答
hibernate二级缓存失败
华为云4核8G,高性能云服务器,免费试用   

还有xml配置文件的错误:

 org.xml.sax.SAXParseException: cvc-complex-type.2.3: Element 'props' cannot have character [children], because the type's content type is element-only.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
at com.s


下面这个是加了这句话导致d

//@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)



 org.hibernate.cache.NoCachingEnabledException: Second-level cache is not enabled for usage [hibernate.cache.use_second_level_cache | hibernate.cache.use_query_cache]

at org.hibernate.cache.impl.NoCachingRegionFactory.buildEntityRegion(NoCachingRegionFactory.java:66)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:261)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:855)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:774)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1398)
... 114 more
2014-7-30 14:14:18 org.apache.cata
举报
共有2个答案 最后回答: 4年前

 Second-level cache is not enabled for usage [hibernate.cache.use_second_level_cache | hibernate.cache.use_query_cache]

需要在配置属性里,

hibernate.cache.use_second_level_cache true

hibernate.cache.use_query_cache true

如此配置


--- 共有 3 条评论 ---
pantrick明显你配置文件中有语法错误嘛,找个正确的对一下就行了 4年前 回复
c罗来中超啦但是在spring里面一打开这个配置文件,就报错:  <prop key="hibernate.cache.use_query_cache">true</prop>     <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop> 4年前 回复
c罗来中超啦十年前就配好了,还是不行,spring里面也有hibernate的session配置 <property name="hibernate.cache.use_second_level_cache">true</property> <property name="hibernate.cache.use_query_cache">true</property> 4年前 回复
org.xml.sax.SAXParseException: cvc-complex-type.2.3: Element 'props' cannot have character [children], because the type's content type is element-only. at com.sun.org.apache.xerces.internal.util....
顶部