struts、spring、mybatis 整合(spring.xml)
来源:互联网 发布:java indexof的用法 编辑:程序博客网 时间:2024/06/06 17:23
<?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:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd">
<context:property-placeholder location="classpath:/db.properties" />
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="user" value="sms"></property>
<property name="jdbcUrl" value="jdbc:oracle:thin:@127.0.0.1:1521:orcl"></property>
<property name="password" value="123456"></property>
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver"></property>
<property name="initialPoolSize" value="5"></property>
<property name="maxPoolSize" value="100"></property>
<property name="autoCommitOnClose" value="true"></property>
</bean>
<!--sqlSessionFactory 需要 mapper.xml 和 数据源 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mapperLocations" value="classpath:com/dxf/Mapper/*Mapper.xml"></property>
</bean>
<bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- basePackage dao 层接口所在包, 包内的接口实现类放到容器中 -->
<property name="basePackage" value="com.dxf.dao"></property>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
</bean>
<!-- 配置Spring的事务管理 -->
<!-- 配置事务切点 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<!-- 配置事务属性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut expression="execution(* com.dxf.Mapper.*Mapper.*(..))"
id="pointcut" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="pointcut" />
</aop:config>
<!-- 配置Struts2的action-->
</beans>
<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:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd">
<context:property-placeholder location="classpath:/db.properties" />
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="user" value="sms"></property>
<property name="jdbcUrl" value="jdbc:oracle:thin:@127.0.0.1:1521:orcl"></property>
<property name="password" value="123456"></property>
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver"></property>
<property name="initialPoolSize" value="5"></property>
<property name="maxPoolSize" value="100"></property>
<property name="autoCommitOnClose" value="true"></property>
</bean>
<!--sqlSessionFactory 需要 mapper.xml 和 数据源 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mapperLocations" value="classpath:com/dxf/Mapper/*Mapper.xml"></property>
</bean>
<bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- basePackage dao 层接口所在包, 包内的接口实现类放到容器中 -->
<property name="basePackage" value="com.dxf.dao"></property>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
</bean>
<!-- 配置Spring的事务管理 -->
<!-- 配置事务切点 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<!-- 配置事务属性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*" />
</tx:advice>
<aop:config>
<aop:pointcut expression="execution(* com.dxf.Mapper.*Mapper.*(..))"
id="pointcut" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="pointcut" />
</aop:config>
<!-- 配置Struts2的action-->
</beans>
阅读全文
0 0
- struts、spring、mybatis 整合(spring.xml)
- struts、spring、mybatis 整合
- Spring-Struts-Mybatis整合
- 整合Struts、Spring、Mybatis
- struts,spring,mybatis框架整合
- Struts+spring+mybatis框架整合
- 一个整合Struts+Spring+MyBatis
- Spring+Mybatis整合配置xml
- 【Spring】XML配置整合Mybatis
- spring-mybatis整合xml配置
- myeclipse+struts+spring+mybatis+mave的框架整合---spring+mybatis
- spring-struts-mybatis整合错误集锦
- Spring、MyBatis、Struts框架整合的jar
- struts-spring-mybatis整合项目搭建
- struts-spring-mybatis整合项目搭建
- ssm整合(Struts、spring、mybatis)
- 三大框架整合struts+spring+mybatis
- SSH spring Struts hibernate 整合 xml
- mysql-存储引擎
- POJ-2251 Dungeon Master(简单的三维bfs)
- MVP + Kotlin
- 详解HTML中的表单元素
- jvm系列(四):jvm调优-命令大全(jps jstat jmap jhat jstack jinfo)
- struts、spring、mybatis 整合(spring.xml)
- python 列表操作
- Android布局知识整理一
- Android 实现自定义闹钟
- 组合数
- 硬链接、软链接和inode
- 简单说 CSS的vertical-align (一)
- toString方法
- C++中remove()函数总结