<?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:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd"> <!-- 1. 配置数据源 --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="url" value="jdbc:oracle:thin:@localhost:1521:lgf"/> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/> <property name="username" value="scott"/> <property name="password" value="admin"/> </bean> <!-- 2. 配置 sqlSessionFactory --> <bean id="sqlSessionFactory" name="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="configurationProperties"> <props> <prop key="cacheEnabled">true</prop> </props> </property> <property name="mapperLocations" value="com.sm.able.*.xml"/> <property name="typeAliasesPackage" value="com.sm.entity"/> </bean> <!-- 3.【可选】配置 SqlSessionTemplate --> <bean name="SqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate"> <constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory"/> </bean> <!-- 4. 配置 mapperScannerConfigurer 扫描配置文件 --> <bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/> <property name="basePackage" value="com.sm.able"/> <property name="sqlSessionTemplateBeanName" value="SqlSessionTemplate"/> </bean> <!-- 5. 配置事务管理器 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> <!-- 6. 配置声名式事务 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="*"/> <tx:method name="get*" read-only="true"/> </tx:attributes> </tx:advice> <!-- 7. 配置事务AOP --> <aop:config> <aop:pointcut expression="execution(* com.sm.able.*.*(..))" id="txPointcut"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"/> </aop:config> <bean id="mapperFactoryBean" abstract="true" class="org.mybatis.spring.mapper.MapperFactoryBean"> <property name="sqlSessionFactory" ref="sqlSessionFactory"/> </bean> <!-- 8. 【可选】配置 mapperFactoryBean 动态生成接口 --> <bean id="deptMapper" parent="mapperFactoryBean"> <property name="mapperInterface" value="com.sm.able.DeptMapper"/> </bean> <!-- 配mapperFactoryBean注入方式 --> <bean id="deptService" class="com.sm.service.DeptService" p:deptMapper-ref="deptMapper"/> <!-- 自动注入方式 --> <bean id="userService" class="com.sm.service.UserService" autowire="byType"/> </beans>
相关推荐
该中间件有如下两个作用 1 在Spring中配置MyBatis工厂类 2 在DAO层使用Spring注入的工具Bean对数据进行操作
mybatis和spring整合方式-带注解,个人经验总结,适合新手学习,欢迎下载
mybatis-spring整合配置文件包mybatis-spring整合配置文件包mybatis-spring整合配置文件包
完整的所有配置文件,不会配置的童鞋可以下载了
本文档是针对ssm编写的spring与mybatis整合的xml配置文件,后期还会发布mybatis配置文件。
MyBatis-Spring 会帮助你将 MyBatis 代码无缝地整合到 Spring 中。 使用这个类库中的类, Spring 将会加载必要的 MyBatis 工厂类和 session 类。 这个类库也提供一个简单的方式来注入 MyBatis 数据映射器和 ...
springmvc + spring + mybatis + maven整合配置文件
spring和mybatis整合配置文件
本文主要是示范基于Maven的MyBatis+Spring的简单使用,其中主要涉及到的是MyBatis的配置使用,另外还有部分log4j的配置使用。
Spring与Mybatis整合,一个简单的demo,包括配置文件等
struts2、spring与mybatis整合 包含简单登录功能 事务配置,运行JunitTestVillageArticle的modify测试。配置说明参考注释
Spring+Spring MVC+MyBatis之零配置之路源代码
这里面涵盖了mybatis与spring 整合开发所需的加入包,各种jar包,十分详细 ,导入项目,配置一下环境变量即可使用,真的是很好的jar包 希望对你有所帮助
struts2+spring+mybatis整合所需jar包,其中还有配置文件的编写方式!
springboot+mybatis整合,利用配置文件生成实体类以及操作数据库的方法,实现后台接收验证码,注册登录功能
springmvc spring mybatis 的配置文件模板 .
关于Mybatis与Spring、SpringMVC整合的简单web工程,spring、springmvc 、mybatis配置文件的书写及各部分的释义。
spring整合mybatis时需要用到的配置文件
真是不好意思,后来发现Dao层注入是在接口,接口实现类完全没必要要了,但是...SSM(struts2+spring3+mybatis)整合示例, 在网上实在找不到现成的,用了2天时间折腾了一个,保证能用....看在这么辛苦的份上,多收点分 嘿嘿....
SpringMVC Spring MyBatis 框架整合需要的jar包 配置文件 工具类