三大框架整合文件配置
来源:互联网 发布:java怎么调用函数 编辑:程序博客网 时间:2024/05/20 07:19
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
<!-- 配置数据源,使用c3p0实现 -->
<bean name="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<!-- 配置数据库驱动 -->
<property name="driverClass">
<value>com.mysql.jdbc.Driver</value>
</property>
<!-- 数据库连接字符串 -->
<property name="jdbcUrl">
<value>jdbc:mysql://localhost:3306/ssh</value>
</property>
<!-- 数据库用户名 -->
<property name="user">
<value>root</value>
</property>
<!-- 数据库密码 -->
<property name="password">
<value>sa</value>
</property>
<!-- 指定数据库连接池的初始化连接数 -->
<property name="initialPoolSize" value="1" />
<!-- 指定连接池中的连接最大空闲时间 -->
<property name="maxIdleTime" value="20" />
<!-- 最大连接数 -->
<property name="maxPoolSize" value="40" />
<!-- 最小连接数 -->
<property name="minPoolSize" value="1" />
</bean>
<!-- 配置sessionFactory -->
<bean name="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="configLocations">
<list>
<value>classpath:hibernate-cfg.xml</value>
</list>
</property>
</bean>
<!-- 配置hibernate的事务管理器 -->
<bean name="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- 配置事务的特性 以save update delete remove 开始的方法,以事务的形式来操作,其他的以可有可无的的形式来操作-->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="remove*" propagation="REQUIRED" />
<tx:method name="get*" propagation="SUPPORTS" read-only="true" />
<tx:method name="query*" propagation="SUPPORTS" read-only="true" />
<tx:method name="*" propagation="SUPPORTS" read-only="true" />
</tx:attributes>
</tx:advice>
<!-- 配置哪些类的哪些方法执行事务管理 -->
<aop:config>
<aop:pointcut expression="execution(* com.huasoft.service..*.*(..))" id="allServiceMethod"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="allServiceMethod"/>
</aop:config>
</beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
<!-- 配置数据源,使用c3p0实现 -->
<bean name="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<!-- 配置数据库驱动 -->
<property name="driverClass">
<value>com.mysql.jdbc.Driver</value>
</property>
<!-- 数据库连接字符串 -->
<property name="jdbcUrl">
<value>jdbc:mysql://localhost:3306/ssh</value>
</property>
<!-- 数据库用户名 -->
<property name="user">
<value>root</value>
</property>
<!-- 数据库密码 -->
<property name="password">
<value>sa</value>
</property>
<!-- 指定数据库连接池的初始化连接数 -->
<property name="initialPoolSize" value="1" />
<!-- 指定连接池中的连接最大空闲时间 -->
<property name="maxIdleTime" value="20" />
<!-- 最大连接数 -->
<property name="maxPoolSize" value="40" />
<!-- 最小连接数 -->
<property name="minPoolSize" value="1" />
</bean>
<!-- 配置sessionFactory -->
<bean name="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="configLocations">
<list>
<value>classpath:hibernate-cfg.xml</value>
</list>
</property>
</bean>
<!-- 配置hibernate的事务管理器 -->
<bean name="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- 配置事务的特性 以save update delete remove 开始的方法,以事务的形式来操作,其他的以可有可无的的形式来操作-->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="remove*" propagation="REQUIRED" />
<tx:method name="get*" propagation="SUPPORTS" read-only="true" />
<tx:method name="query*" propagation="SUPPORTS" read-only="true" />
<tx:method name="*" propagation="SUPPORTS" read-only="true" />
</tx:attributes>
</tx:advice>
<!-- 配置哪些类的哪些方法执行事务管理 -->
<aop:config>
<aop:pointcut expression="execution(* com.huasoft.service..*.*(..))" id="allServiceMethod"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="allServiceMethod"/>
</aop:config>
</beans>
0 0
- 三大框架整合文件配置
- ssh三大框架整合的配置
- 三大框架的配置整合
- 三大框架整合
- 三大框架整合
- 三大框架整合
- 手动配置三大框架整合,Spring+Struts2+Hibernate
- 手动配置三大框架整合,Spring+Struts2+Hibernate
- SSH三大框架整合配置详细步骤(1)
- SSH三大框架整合配置详细步骤(2)
- SSH三大框架整合配置详细步骤(3)
- 手动配置三大框架整合:Spring+Struts2+mybatis
- 手动配置三大框架整合:Spring+Struts2+mybatis
- 三大框架整合配置hibernate延迟加载
- 基于XML配置的SSH三大框架整合
- SSM三大框架整合配置(1)-----SpringMVC
- SSM三大框架整合配置(2)-----Spring+Mybatis
- spring+struts+mybatis三大框架整合配置
- 问题集锦
- javascript对象系统小得
- 理解矩阵(三)
- NYOJ 53 不高兴的小明
- Leetcode: Same Tree
- 三大框架整合文件配置
- 负数取模运算
- 深度学习 Deep Learning简介 (二):浅层学习(Shallow Learning)和深度学习(Deep Learning)
- 几个技巧让Windows 7跑得更快
- android-状态栏SIM卡信号显示(一)
- Java面试宝典系列之基础排序算法
- convertView&setTag方法的一点理解
- 在Ubuntu中点斜杠和点空格点斜杠执行脚本之间的区别
- uestc 1904 树上的鸟儿