<?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: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/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd" >
<!-- 打开注解注入 -->
<context:annotation-config/>
<context:component-scan base-package="com.hkwy" />
<!-- 添加AOP annotation支持 -->
<aop:aspectj-autoproxy/>
<!-- 配置数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<!-- 基本参数 -->
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://localhost:3306/spring1"></property>
<property name="username" value="root"></property>
<property name="password" value="root"></property>
<!--配置连接池的参数 -->
<property name="initialSize" value="1"></property>
<!-- 连接池的最大数量 -->
<property name="maxActive" value="500"></property>
<!-- 空闲时 连接数降低到最小值 -->
<property name="maxIdle" value="2"></property>
<!-- 空闲时连接池的最小值 -->
<property name="minIdle" value="1"></property>
<!-- 最大等待时间 -->
<property name="maxWait" value="1000"></property>
</bean>
<!--配置hibernate SessionFactory annotation方式 -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<!-- 将数据源配置进来 -->
<property name="dataSource" ref="dataSource"></property>
<!--对应的实体类,只需要指定包 -->
<property name="packagesToScan">
<value>com.hkwy.entity</value>
</property>
<!-- 配置hibernate其他参数 -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<!--将hibernate交给Spring管理其事务 -->
<!--配置事务管理器 -->
<bean id="txmanager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!--配置Spring的AOP 来管理事务 -->
<aop:config>
<!-- 配置需要管理的dao -->
<aop:pointcut expression="execution (* com.hkwy.dao.*.*(..))" id="aoph"/>
<!--通过advisor来确定具体要加入事务控制的方法 -->
<aop:advisor advice-ref="txadvice" pointcut-ref="aoph"/>
</aop:config>
<!-- 配置advice 来确定哪些数据操作需要加入到事务控制 -->
<tx:advice id="txadvice" transaction-manager="txmanager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice> </beans>

最新文章

  1. (转)android中颜色矩阵colormatrix
  2. javascript new
  3. pH 值与曝气对硝化细菌硝化作用的影响
  4. protocol buffers的使用示例[z]
  5. poj 1556 (Dijkstra + Geometry 线段相交)
  6. oracle查看字符集后修改oracle服务端和客户端字符集的步骤
  7. linux awk命令学习
  8. 【转】DynDNS使用随笔
  9. Hibernate---O/R Mapping
  10. 重写,string创建内存问题
  11. (转)JAVA HashSet 去除重复值原理
  12. 磁盘异步I / O在Windows上显示为同步
  13. react学习笔记(二)
  14. Python基础【day01】:Hello World程序(二)
  15. Android 动画:你真的会使用插值器与估值器吗?
  16. HTTP、TCP、IP协议常见面试题
  17. Spring ResponseEntity
  18. elasticsearch分词器ik
  19. java.util.logging.Logger使用详解 (转)
  20. 问答项目---登陆账号密码登陆做AJAX异步校验

热门文章

  1. Html Agility Pack 解析Html
  2. ASP.NET Aries 入门开发教程2:配置出一个简单的列表页面
  3. 微软.NET Core RC2正式发布,横跨所有平台
  4. 背后的故事之 - 快乐的Lambda表达式(一)
  5. DB1:数据库的创建和文件的修改
  6. 移动硬盘不能识别的常见7种解决方案 ~ By 逆天经验
  7. Android混合开发之WebView与Javascript交互
  8. 《LoadRunner12七天速成宝典》签售会2016-12-17北京
  9. 【JQ基础】数组
  10. 品牌营销:不要Beat,要逼格!