123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <?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:aop="http://www.springframework.org/schema/aop"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
- <bean id="sessionFactory"
- class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
- <property name="dataSource" ref="poolDataSource" />
- <property name="packagesToScan">
- <list>
- <!-- 通用模块 -->
- <value>classpath*:com.rtrh.common.modules.*.po</value>
- <!-- 核心插件 -->
- <value>classpath*:com.rtrh.core.plugins.*.po</value>
- <value>classpath*:com.rtrh.projects.modules.*.po</value>
- </list>
- </property>
- <property name="hibernateProperties">
- <value>
- <!-- 设置数据库方言 -->
- hibernate.dialect=org.hibernate.dialect.MySQLDialect
- <!-- 设置自动创建|更新|验证数据库表结构 -->
- hibernate.hbm2ddl.auto=update
- <!-- 是否在控制台显示sql -->
- hibernate.show_sql=true
- <!-- 是否格式化sql,优化显示 -->
- hibernate.format_sql=true
- <!-- 是否开启二级缓存 -->
- hibernate.cache.use_second_level_cache=true
- <!-- 是否开启查询缓存 -->
- hibernate.cache.use_query_cache=false
- <!-- 缓存region -->
- hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
- <!-- 数据库批量查询最大数 -->
- hibernate.jdbc.fetch_size=50
- <!-- 数据库批量更新、添加、删除操作最大数 -->
- hibernate.jdbc.batch_size=50
- <!-- 是否自动提交事务 -->
- hibernate.connection.autocommit=false
- <!-- 指定hibernate在何时释放JDBC连接 -->
- hibernate.connection.release_mode=auto
- <!-- 创建session方式 hibernate4.x 的方式 -->
- hibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext
- <!-- javax.persistence.validation.mode默认情况下是auto的,就是说如果不设置的话它是会自动去你的classpath下面找一个bean-validation**包
- 所以把它设置为none即可 -->
- javax.persistence.validation.mode=none
- </value>
- </property>
- <property name="entityInterceptor">
- <ref bean="entityInterceptor" />
- </property>
- <property name="mappingLocations">
- <list>
- <!-- 通用模块 -->
- <value>classpath*:/com/rtrh/common/modules/*/po/*.hbm.xml</value>
- <!-- 核心插件 -->
- <value>classpath*:/com/rtrh/core/plugins/*/po/*.hbm.xml</value>
- <value>classpath*:/com/rtrh/projects/modules/*/po/*.hbm.xml</value>
- </list>
- </property>
- </bean>
- <bean id="eventListener" class="com.rtrh.core.repository.hibernate.EventListener" />
- <bean id="entityInterceptor" class="com.rtrh.core.repository.hibernate.EntityInterceptor" />
- <bean id="transactionManager"
- class="org.springframework.orm.hibernate4.HibernateTransactionManager">
- <property name="sessionFactory" ref="sessionFactory" />
- </bean>
- <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
- <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />
- <aop:aspectj-autoproxy/>
- <tx:advice id="txAdvice" transaction-manager="transactionManager">
- <tx:attributes>
- <tx:method name="*" rollback-for="java.lang.Exception" />
- <tx:method name="*" rollback-for="java.lang.RuntimeException" />
- <tx:method name="create*" propagation="REQUIRED" />
- <tx:method name="save*" propagation="REQUIRED" />
- <tx:method name="add*" propagation="REQUIRED" />
- <tx:method name="update*" propagation="REQUIRED" />
- <tx:method name="remove*" propagation="REQUIRED" />
- <tx:method name="del*" propagation="REQUIRED" />
- <tx:method name="import*" propagation="REQUIRED" />
- </tx:attributes>
- </tx:advice>
- <aop:config proxy-target-class="true">
- <!-- 核心插件事务 -->
- <aop:pointcut id="corePluginServiceMethods" expression="execution(* com.rtrh.core.plugins..*.*(..))" />
- <!-- 通用模块事务 -->
- <aop:pointcut id="commModulesServiceMethods" expression="execution(* com.rtrh.common.modules..*.*(..))" />
- <!-- 扩展模块事务 -->
- <aop:pointcut id="extModulesServiceMethods" expression="execution(* com.rtrh.ext.modules..*.*(..))" />
- <aop:pointcut id="projectsModulesServiceMethods" expression="execution(* com.rtrh.projects.modules..*.*(..))" />
- <aop:advisor advice-ref="txAdvice" pointcut-ref="corePluginServiceMethods" />
- <aop:advisor advice-ref="txAdvice" pointcut-ref="commModulesServiceMethods" />
- <aop:advisor advice-ref="txAdvice" pointcut-ref="extModulesServiceMethods" />
- <aop:advisor advice-ref="txAdvice" pointcut-ref="projectsModulesServiceMethods" />
- </aop:config>
- <!-- hibernate 缓存
- <bean id="cacheManagerEhcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
- <property name="configLocation">
- <value>classpath:/ehcache.xml</value>
- </property>
- <property name="shared" value="true"/>
- </bean>
- -->
- <!-- druid spring monitor setting -->
- <bean id="druid-stat-interceptor" class="com.alibaba.druid.support.spring.stat.DruidStatInterceptor"/>
- <bean id="druid-stat-pointcut" class="org.springframework.aop.support.JdkRegexpMethodPointcut" scope="prototype">
- <property name="patterns">
- <list>
- <value>com.rtrh.projects.*</value>
- </list>
- </property>
- </bean>
- <aop:config proxy-target-class="true">
- <aop:advisor advice-ref="druid-stat-interceptor" pointcut-ref="druid-stat-pointcut"/>
- </aop:config>
- </beans>
|