spring整合Mybatis


一、导 入 mybatis 所 有 jar 和 spring 基 本包,spring-jdbc,spring-tx,spring-aop,spring-web,mybatis-spring等包

配置applicationContext.xml

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4     xsi:schemaLocation="http://www.springframework.org/schema/beans
 5         http://www.springframework.org/schema/beans/spring-beans.xsd">
 6         
 7     <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
 8         <property name="url" value="jdbc:mysql://localhost:3306/bjsxt">property>
 9         <property name="username" value="root">property>
10         <property name="password" value="155251">property>
11         <property name="driverClassName" value="com.mysql.cj.jdbc.Driver">property>
12     bean>
13     
14     <bean id="factory" class="org.mybatis.spring.SqlSessionFactoryBean">
15         <property name="dataSource" ref="dataSource">property>
16     bean>
17     
18     <bean id="mapper" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
19         
20         <property name="basePackage" value="com.bjsxt">property>
21         
22         <property name="sqlSessionFactory" ref="factory">property>
23     bean>
24     
25     <bean id="impl" class="com.briup.serivce.impl.AirPortSerivceImpl">
26         <property name="ariport" ref="airPortMapper">property>
27     bean>
28 beans>