项目总结SpringMVC+hibernate框架 原理(MVC) applicationContext.xml 文件(3)
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:task="http://www.springframework.org/schema/task" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsdhttp://www.springframework.org/schema/taskhttp://www.springframework.org/schema/task/spring-task-3.0.xsd"><task:annotation-driven /><task:scheduled-tasks><task:scheduled ref="clearGenNoJob" method="work"cron="0 0 3 * * ?" /></task:scheduled-tasks><bean id="clearGenNoJob" class="common.routinetask.ClearGenNoJob"><property name="commonService" ref="commonService" /></bean><!-- root webapplication context : 这个context下面配置数据库相关设置, 和一些全局的Bean注入 --><bean id="MySQLDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"><property name="driverClass" value="com.mysql.jdbc.Driver" /><property name="jdbcUrl"value="jdbc:mysql://localhost:3306/database?useUnicode=true&characterEncoding=UTF-8" /><property name="user" value="user" /><property name="password" value="password" /><property name="minPoolSize" value="3" /><property name="maxPoolSize" value="15" /><property name="idleConnectionTestPeriod" value="28000" /></bean><bean id="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><property name="dataSource"><ref bean="MySQLDataSource" /></property><property name="hibernateProperties"><props><prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop><prop key="hibernate.show_sql">true</prop><prop key="hibernate.max_fetch_depth">10</prop><prop key="hibernate.jdbc.batch_size">100</prop><prop key="hibernate.cache.use_second_level_cache">false</prop></props></property><property name="mappingResources"><list><!-- common --><value>common/util/vo/FormSequence.hbm.xml</value><!-- system --><value>com/xiangmu/system/vo/SysUser.hbm.xml</value><value>com/xiangmu/system/vo/SysDepart.hbm.xml</value><!-- ……………………………………………………………………………… --></list></property></bean><!-- 事务管理 --><!-- hibernate事务托管 --><bean id="transactionManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager"><property name="sessionFactory"><ref local="sessionFactory" /></property></bean><!-- 事务管理拦截器 Begin --><bean id="transactionInterceptor"class="org.springframework.transaction.interceptor.TransactionInterceptor"><property name="transactionManager" ref="transactionManager" /><!-- 配置事务属性 --><property name="transactionAttributes"><props><prop key="update*">PROPAGATION_REQUIRED,-Exception</prop><prop key="insert*">PROPAGATION_REQUIRED,-Exception</prop><prop key="delete*">PROPAGATION_REQUIRED,-Exception</prop><prop key="import*">PROPAGATION_REQUIRED,-Exception</prop><prop key="find*">PROPAGATION_NEVER,readOnly</prop><prop key="get*">PROPAGATION_NEVER,readOnly</prop><prop key="run">PROPAGATION_SUPPORTS</prop><prop key="*">PROPAGATION_REQUIRED</prop></props></property></bean><!-- 系统日志记录服务 Begin --><bean id="globalSysLogDAO" class="com.xiangmu.system.dao.SysLogDAOImpl"><property name="sessionFactory"><ref bean="sessionFactory" /></property></bean><bean id="globalSysLogService" class="com.xiangmu.system.service.SysLogServiceImpl"><property name="sysLogDAO"><ref bean="globalSysLogDAO" /></property></bean><!-- 系统日志记录服务 End --><!-- 权限管理拦截器Begin --><bean id="rightValidationService" class="common.service.RightValidationService"></bean><bean id="rightInterceptor" class="common.filter.RightInterceptor"><property name="rightValidationService"><ref bean="rightValidationService" /></property></bean><!-- 权限管理拦截器End --><!-- 单号产生器Begin --><bean id="commonService" class="common.service.CommonService"><property name="sessionFactory" ref="sessionFactory" /></bean><!-- 单号产生器End --><!-- SPRING 定时器Begin --><!-- SPRING 定时器End --><!-- 国际化设置,包括多语言的变更与切换 --><bean id="localeResolver"class="org.springframework.web.servlet.i18n.SessionLocaleResolver"><property name="defaultLocale" value="zh_CN" /></bean><bean id="localeChangeInterceptor"class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"><property name="paramName" value="language" /></bean><bean id="messageSource"class="org.springframework.context.support.ResourceBundleMessageSource"><property name="basenames"><list><value>language-res/messages</value><value>language-res/errors</value></list></property></bean><!-- 国际化设置,包括多语言的变更与切换结束 --><!-- 公共类库 --><bean id="commonComponentsDAO" class="common.baseclass.CommonComponentsDAO"><property name="sessionFactory"><ref bean="sessionFactory" /></property></bean><!-- 每个Module的事务配置,将所有事务放到Service层 --><bean id="formManager" class="common.util.FormManager" /><bean id="JSONUtil" class="common.util.JSONUtil" /><!-- 事务管理拦截器 End --><!-- 禁止表单重复提交(表单未处理前不可以再次提交请求) Start --><bean id="denyDuplicateFormSubmitInterceptor" class="common.filter.DenyDuplicateFormSubmitInterceptor"><property name="actionRegEx"value=".*action=([(insert)(update)(saveAudit)]){1}.*" /><property name="createTokenRegEx" value=".*action=([(toUpdate)(toInsert)]){1}.*" /><property name="formManager" ref="formManager"></property><property name="jsonUtil" ref="JSONUtil"></property></bean><!-- 禁止表单重复提交(表单未处理前不可以再次提交请求) End --></beans>