hibernate 3.3 配置 oscache 二级缓存
2015-05-25 00:37
357 查看
hibernate 3.3 配置 oscache 二级缓存
缺少引用包错误
1.Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
出现原因:hibernate 3.3.2 的 slf4j-api-1.5.8.jar 包中并没有加入 org.slf4j.impl.StaticLoggerBinder 包
解决方法:下载slf4j-1.5.8.zip,找到 slf4j-log4j12-1.5.8.jar 包导入自己的项目
下载地址:http://www.slf4j.org/dist/slf4j-1.5.8.zip
2.Exception in thread "main" java.lang.ExceptionInInitializerError at test.QueryTwoLevelCache.main(QueryTwoLevelCache.java:18)
Caused by: org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge]
出现原因:hibernate 3.3.2 的 oscache-2.1.jar 包中并没有导入 commons-logging.jar 包
解决方法:在oscache官方重新下载一个 oscache 找到 commons-logging.jar 包导入自己的项目
hibernate配置oscache 文件 hibernate.hbm.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/my_hibernate</property>
<property name="connection.username">root</property>
<property name="connection.password">123456</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="format_sql">false</property>
<property name="cache.use_second_level_cache">true</property>
<property name="cache.provider_class">org.hibernate.cache.OSCacheProvider</property>
<property name="hibernate.cache.provider_configuration_file_resource_path">ehcache.xml
</property>
<property name="hibernate.generate_statistics">true</property>
<mapping resource="domain/Student.hbm.xml"/>
<class-cache usage="read-write" class="domain.Student"/>
</session-factory>
</hibernate-configuration>
缺少引用包错误
1.Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
出现原因:hibernate 3.3.2 的 slf4j-api-1.5.8.jar 包中并没有加入 org.slf4j.impl.StaticLoggerBinder 包
解决方法:下载slf4j-1.5.8.zip,找到 slf4j-log4j12-1.5.8.jar 包导入自己的项目
下载地址:http://www.slf4j.org/dist/slf4j-1.5.8.zip
2.Exception in thread "main" java.lang.ExceptionInInitializerError at test.QueryTwoLevelCache.main(QueryTwoLevelCache.java:18)
Caused by: org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge]
出现原因:hibernate 3.3.2 的 oscache-2.1.jar 包中并没有导入 commons-logging.jar 包
解决方法:在oscache官方重新下载一个 oscache 找到 commons-logging.jar 包导入自己的项目
hibernate配置oscache 文件 hibernate.hbm.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/my_hibernate</property>
<property name="connection.username">root</property>
<property name="connection.password">123456</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="format_sql">false</property>
<property name="cache.use_second_level_cache">true</property>
<property name="cache.provider_class">org.hibernate.cache.OSCacheProvider</property>
<property name="hibernate.cache.provider_configuration_file_resource_path">ehcache.xml
</property>
<property name="hibernate.generate_statistics">true</property>
<mapping resource="domain/Student.hbm.xml"/>
<class-cache usage="read-write" class="domain.Student"/>
</session-factory>
</hibernate-configuration>
相关文章推荐
- Hibernate EhCache 二级缓存配置.pdf
- hibernate Search 继续研究 增加 hibernate memcache 二级缓存 配置成功 附件maven代码(2)
- hibernate二级缓存配置总结
- Hibernate4之二级缓存配置
- Hibernate 4.2.2配置二级缓存的详细过程
- 【JPA】使用hibernate的jpa的二级缓存配置
- Spring视频学习(十三)配置Hibernate的二级缓存
- 【j2ee spring】22、关于spring中配置hibernate的二级缓存
- spring+hibernate 二级缓存 配置+java使用实例
- Hibernate4之二级缓存配置
- Hibernate ehcache 配置二级缓存及说明
- hibernate4.1.7+ehcache2.4.3配置二级缓存
- hibernate中二级缓存配置详细解析
- maven工程中hibernate的二级缓存ehcache的配置
- Hibernate4之二级缓存配置
- hibernate二级缓存:hibernate3 2级缓存Cache的配置及测试
- 为Spring集成的Hibernate配置二级缓存
- hibernate 如何配置二级缓存
- Hibernate二级缓存的配置及
- hibernate二级缓存 Ehcache配置详解