1、引入mybatis 和mybatis-spring 依赖
<dependency> <groupId>org.mybatis</groupId> <artifactId>Mybatis-Spring</artifactId> <version>2.0.6</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.5.9</version> </dependency>
2、配置bean工厂、 mapper扫描器
<!--配置mybatis工厂--> <bean class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource " ref="dataSource"/> <!-- 引入mybatis核心配置文件--> <property name="configLocation" value="classpath:mybatis-config.xml"/> </bean> <!--配置mapper扫描--> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="cn.com.sise.dao"/> </bean>