博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hiberante 二级缓存设置
阅读量:6852 次
发布时间:2019-06-26

本文共 4721 字,大约阅读时间需要 15 分钟。

<?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>

转载地址:http://rquyl.baihongyu.com/

你可能感兴趣的文章
db2缓冲池调优
查看>>
Sicily_How can I go
查看>>
NYOJ_456_邮票分你一半
查看>>
NYOJ_44_子串和
查看>>
kafka整理笔记笔记
查看>>
The Zip, GZip, BZip2 and Tar Implementation For .NET
查看>>
BZOJ4521:[CQOI2016]手机号码(数位DP)
查看>>
C/C++ rand()产生随机数 模拟 掷骰子 小游戏代码
查看>>
openfire 访问 user service 插件 访问不到
查看>>
linux 下 easy_install 安装
查看>>
生成唯一编码
查看>>
C# Directory.GetFiles()获取文件时如果是根目录时有隐藏文件则报错的处理
查看>>
POJ 3320 (尺取法+Hash)
查看>>
名校公开课网站汇总
查看>>
CodeForces 620E New Year Tree
查看>>
ZOJ 2059 The Twin Towers
查看>>
阿里云系列——5.网站云解析快速配置(简单+免费+详细+最新)
查看>>
python简单爬虫爬取百度百科python词条网页
查看>>
分享git的常用命令
查看>>
《代码大全》阅读笔记-13-不常见的数据类型
查看>>