-
Notifications
You must be signed in to change notification settings - Fork 2
如何支持mybatis
halower edited this page Mar 14, 2018
·
1 revision
本章将演示如何使用在xml文件 1、 添加依赖
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
2、添加mappers/xxx.xml,mybatis-config.xml
- mybatis-config.xml
<?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>
<typeAliases>
<package name="cn.halower.model"/>
</typeAliases>
<mappers>
<mapper resource="mappers/TestMapper.xml"/>
</mappers>
</configuration>
- 添加sql脚本映射文件
<?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="cn.halower.dao">
<select id="selectUserById" resultType="User">
select * from users where id = #{userId}
</select>
</mapper>