通过Mybatis-Springspring与mybatis整合
来源:互联网 发布:js替换所有换行符 编辑:程序博客网 时间:2024/05/18 03:35
1,首先配置数据源
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"><property name="driverClass" value="${jdbc.driverClass}" /><property name="jdbcUrl" value="${jdbc.api.url}" /><property name="user" value="${jdbc.api.username}" /><property name="password" value="${jdbc.api.password}" /><property name="maxPoolSize"><value>50</value></property> <property name="minPoolSize"><value>2</value></property> <property name="initialPoolSize"><value>3</value></property> <property name="acquireIncrement"><value>5</value></property> <property name="maxStatements"><value>0</value></property> <property name="maxStatementsPerConnection"><value>0</value></property> <property name="maxIdleTime"><value>300</value></property> <property name="checkoutTimeout"><value>20000</value></property></bean>
2,myibatis配置,使其支持注解和配置文件形式
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><property name="dataSource" ref="dataSource" /><property name="configLocation" value="classpath:mybatis/mybatis.xml" /><property name="typeAliasesPackage" value="com.joeyon.base.api.models,com.models" /><property name="mapperLocations" value="classpath:mybatis/**/*mapper.xml" /></bean><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="com.joeyon.base.api.mappers" /></bean>
3,配置事物管理器
<bean name="transactionManager"class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource"></property></bean>4,配置事物控制
<tx:advice id="userTxAdvice" transaction-manager="transactionManager"><tx:attributes><tx:method name="delete*" propagation="REQUIRED" /><tx:method name="insert*" propagation="REQUIRED" /><tx:method name="update*" propagation="REQUIRED" /><tx:method name="add*" propagation="REQUIRED" /></tx:attributes></tx:advice><aop:config proxy-target-class="true"><aop:pointcut id="pc"expression="execution(public * com.joeyon.base.api.services..*.*(..))" /><aop:advisor pointcut-ref="pc" advice-ref="userTxAdvice" /></aop:config>
参考:http://haoshenqi.blogchina.com/1533893.html
http://blog.csdn.net/joeyon1985
0 0
- 通过Mybatis-Springspring与mybatis整合
- 整合Mybatis 与 Spring3
- mybatis 与 ehcache 整合
- spring与mybatis整合
- 整合spring与myBatis
- mybatis 与 spring 整合
- mybatis与spring整合
- Mybatis与Ehcache整合
- mybatis与spring整合
- mybatis与spring整合
- spring与mybatis整合
- spring与mybatis整合
- springMVC与MyBatis整合
- Spring与Mybatis整合
- Mybatis与Ehcache整合
- Mybatis与Spring整合
- spring与mybatis整合
- mybatis与spring整合
- ubuntu 12.04 LTS 出现Could not initialize the package information
- 大公司里怎样开发和部署前端代码?[转自知乎]
- SAE下整合头像上传插件
- 飞思卡尔kinetis L系列芯片之电源管理
- Log4j配置详解
- 通过Mybatis-Springspring与mybatis整合
- Android开发随笔
- ubuntu 10.04 安装ibus 拼音输入法
- iOS UIDevice的使用
- IOS 内存管理
- python 多线程编程总结(实验多线程判断网址是否在线)
- 什么是堆和栈?它们在哪儿?
- 扩展文件大小的两个方法
- 成为开源编程高手的11个技巧【转】