我在啓動應用程序時遇到錯誤,僅當我在域對象上添加@cache(usage=CacheConcurrencyStrategy.READ_WRITE)
註釋時纔得到此例外。如果我只使用註釋@Cacheable(true)
它不會給這個錯誤。應用程序中使用了二級緩存,但未提供屬性hibernate.cache.region.factory_class
org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given, please either disable second level cache or set correct region factory class name to property hibernate.cache.region.factory_class (and make sure the second level cache provider, hibernate-infinispan, for example, is available in the classpath).
怎麼可能認爲,只要Cacheble它是能夠找到工廠並使用@Cache
標註難道不是嗎?
的persistence.xml
<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.cache.use_query_cache" value="true"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider"/>
<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.ehcache.EhCacheRegionFactory"/>
我使用Hibernate的4.x版本JPA 2.1在JBoss EAP 6
運氣好嗎?你試過解決方案嗎 – LearningPhase