<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"
default-lazy-init="false">

<description>Spring公共配置 </description>

<!-- 使用annotation 自动注册bean, 并保证@Required、@Autowired的属性被注入 -->
<context:component-scan base-package="com.zendaimoney.uc">
<context:exclude-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>
<!-- Hibernate配置 -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="namingStrategy">
<bean class="org.hibernate.cfg.ImprovedNamingStrategy" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.EhCacheProvider</prop>
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.EhCacheRegionFactory</prop>
<prop key="hibernate.cache.region.factory_class"> org.hibernate.cache.SingletonEhCacheRegionFactory</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.use_structured_entries">true</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.provider_configuration_file_resource_path">ehcache.xml</prop>
</props>
</property>
<property name="packagesToScan" value="com.zendaimoney.*.entity" />
</bean>

<!-- 事务管理器配置,单数据源事务 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<!-- 使用annotation定义事务 -->
<tx:annotation-driven transaction-manager="transactionManager"
proxy-target-class="true" />

<context:property-placeholder
ignore-unresolvable="true" location="classpath*:/application.properties" />

<!-- 数据源配置, 使用DBCP数据库连接池 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<!-- Connection Info -->
<property name="driverClassName" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />

<!-- Connection Pooling Info -->
<property name="maxActive" value="${dbcp.maxActive}" />
<property name="maxIdle" value="${dbcp.maxIdle}" />
<property name="defaultAutoCommit" value="false" />
<!--removeAbandoned: 是否自动回收超时连接 -->
<property name="removeAbandoned" value="true" />
<!--removeAbandonedTimeout: 超时时间(以秒数为单位) -->
<property name="removeAbandonedTimeout" value="10" />
<!--maxWait: 超时等待时间以毫秒为单位 1000等于60秒 -->
<property name="maxWait" value="500" />

<!-- 连接Idle一个小时后超时 -->
<property name="timeBetweenEvictionRunsMillis" value="3600000" />
<property name="minEvictableIdleTimeMillis" value="3600000" />
</bean>
<bean id="dozerBeanMapper" class="org.dozer.DozerBeanMapper">
</bean>

<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource">
<ref local="dataSource" />
</property>
</bean>
<bean id="springContextHelper" class="com.zendaimoney.uc.utils.SpringContextHelper"
lazy-init="false"></bean>
</beans>

--------------------------------------------------------------------------------------------------------------------

ehcache.xml

<?xml version="1.0" encoding="UTF-8"?>
<ehcache updateCheck="false">

<diskStore path="java.io.tmpdir/hibernate/uc-web" />

<!-- DefaultCache setting. -->
<defaultCache maxEntriesLocalHeap="10000" eternal="false" timeToIdleSeconds="300" timeToLiveSeconds="600"
overflowToDisk="true" maxEntriesLocalDisk="100000" />

</ehcache>

转载于:https://www.cnblogs.com/adolfmc/p/3250355.html

hiberante 二级缓存设置相关推荐

  1. 一级缓存,二级缓存设置

    /* *作者:呆萌老师 *☑csdn认证讲师 *☑51cto高级讲师 *☑腾讯课堂认证讲师 *☑网易云课堂认证讲师 *☑华为开发者学堂认证讲师 *☑爱奇艺千人名师计划成员 *在这里给大家分享技术.知识 ...

  2. MyBatis 延迟加载,一级缓存,二级缓存设置

    什么是延迟加载 resultMap中的association和collection标签具有延迟加载的功能. 延迟加载的意思是说,在关联查询时,利用延迟加载,先加载主信息.使用关联信息时再去加载关联信息 ...

  3. ssh整合hibernate 使用spring管理hibernate二级缓存,配置hibernate4.0以上二级缓存

    ssh整合hibernate 使用spring管理hibernate二级缓存,配置hibernate4.0以上二级缓存 hibernate  : Hibernate是一个持久层框架,经常访问物理数据库 ...

  4. 22-Mybatis缓存相关设置对一级缓存和二级缓存的影响

    上一篇:21-Mybatis二级缓存https://blog.csdn.net/fsjwin/article/details/109685894 缓存相关的设置1. <setting name= ...

  5. MyBatis 延迟加载,一级缓存(sqlsession级别)、二级缓存(mapper级别)设置

    什么是延迟加载 resultMap中的association和collection标签具有延迟加载的功能. 延迟加载的意思是说,在关联查询时,利用延迟加载,先加载主信息.使用关联信息时再去加载关联信息 ...

  6. Hibernate学习(九)———— 二级缓存和事务级别详讲

    序言 这算是hibernate的最后一篇文章了,下一系列会讲解Struts2的东西,然后说完Struts2,在到Spring,然后在写一个SSH如何整合的案例.之后就会在去讲SSM,在之后我自己的个人 ...

  7. hibernate学习之旅之二级缓存

    最近学习的缓存,感觉有了进一步的认识,也感觉到自己只是浅浅的利用缓存,如果真正能够的能够优化hibernate的性能,还需要更加深入(对于项目而言) 好了废话不说了. 讲到Hibernate的二级缓存 ...

  8. JavaEE Tutorials (15) - 对Java持久化API应用使用二级缓存

    15.1二级缓存概述190 15.1.1控制实体是否可以缓存191 15.2指定缓存模式设置来提高性能192 15.2.1设置缓存获取和存储模式192 15.2.2通过编程方式控制二级缓存194 转载 ...

  9. 深入浅出 MyBatis 的一级、二级缓存机制

    一.MyBatis 缓存 缓存就是内存中的数据,常常来自对数据库查询结果的保存.使用缓存,我们可以避免频繁与数据库进行交互,从而提高响应速度. MyBatis 也提供了对缓存的支持,分为一级缓存和二级 ...

最新文章

  1. 显卡不够时,如何训练大型网络
  2. Oracle伪列ROWID和ROWNUM
  3. POJ - 1459 Power Network(网络流-最大流)
  4. 【快速入门Linux】8_Linux命令—系统信息相关命令(时间、磁盘、进程)
  5. docker 保存 环境持久化_为什么 Docker 适合微服务架构?
  6. Canceled future for execute_request message before replies were done The Kernel crashed while execut
  7. matlab 正弦曲线平均值,如何用matlab做正弦曲线拟合
  8. 用JQuery实现简单计时答题游戏
  9. 6,美国2012年总统候选人政治献金数据分析
  10. 算法导论第一,第二部分总结
  11. 判断是手机还是平板html,“吃鸡”用平板好还是手机好?大神给出了答案,不同理解不同格局...
  12. 105道CSS 面试知识点总结
  13. 利用DOCX文档远程模板注入执行宏代码
  14. LaTex论文排版 | (23) LaTex中的正上、正下标记以及各种箭头符号总结
  15. 阿里php开发规范,阿里巴巴java开发手册学习记录,php版
  16. mysql开源内库_记一次内衣渗透测试
  17. Today今天便利店的梦想:准独角兽的雄心与挑战 1
  18. 基于stm32的OLED显示屏显示
  19. LED照明提供了额外的奖金和环境效益
  20. Java CountDownLatch应用

热门文章

  1. 闭眼入!采集 Nginx 日志的几种方式!
  2. 阿里P9架构师分享:通俗易懂Redis原理,都是你没看过的
  3. 如果我是一线技术主管……
  4. Tensorflow LSTM时间序列预测的尝试
  5. Android --- ImageView的scaleType属性讲解
  6. Spring Data JPA_多表关联查询中应该注意的问题
  7. jQuery核心函数的使用总结
  8. git 修改分支名字_开发中必须要掌握的 Git 技巧
  9. Py之pandas:利用where、replace等函数对dataframe格式数据按照条件进行数据替换
  10. ML之xgboost:利用xgboost算法对breast_cancer数据集实现二分类预测并进行graphviz二叉树节点图可视化