maven依赖
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
主配置文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<setting name="lazyLoadingEnabled" value="true"/>
<setting name="aggressiveLazyLoading" value="false"/>
</settings>
<typeAliases>
<package name=""/>
</typeAliases>
<environments default="">
<environment id="">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value=""/>
<property name="url" value=""/>
<property name="username" value=""/>
<property name="password" value=""/>
</dataSource>
</environment>
</environments>
<mappers>
<package name=""/>
</mappers>
</configuration>
mapper配置文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="">
<resultMap id="" type="">
<id property="" column=""/>
<result property="" column=""/>
<association property="" javaType="" column="" select="">
<id property="" column=""/>
<result property="" column=""/>
</association>
<collection property="" ofType="" column="" select="">
<id property="" column=""/>
<result property="" column=""/>
</collection>
</resultMap>
<insert id="" parameterType="" parameterMap="">
<where>
<if test=""></if>
</where>
</insert>
<delete id="" parameterType="" parameterMap="">
<where>
<if test=""></if>
</where>
</delete>
<update id="" parameterType="" parameterMap="">
<where>
<if test=""></if>
</where>
</update>
<select id="" parameterType="" parameterMap="" resultType="" resultMap="">
<where>
<if test=""></if>
</where>
</select>
</mapper>