Spring Boot集成mybatis

来源:互联网 发布:gta5ol 捏脸数据 编辑:程序博客网 时间:2024/05/21 09:54
1、勾选 mybatis、devtools
2、创建实体类

3、编写mapper

4、编写mappe.xml
GirlMapper.xml
<?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE mapper (View Source for full doctype...)>
-<mapper namespace="com.hint.mapper.GirlMapper">
-<resultMap id="BaseResultMap" type="com.hint.domain.Girl">
  <id column="id" property="id" jdbcType="INTEGER" />
  <result column="girl_name" property="name" jdbcType="VARCHAR" />
  <result column="girl_birthday" property="birthday" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Base_Column_List">id, girl_name, girl_birthday</sql>
-<select id="selectById" resultMap="BaseResultMap" parameterType="java.lang.Integer">
  select
  <include refid="Base_Column_List" />
  from girl where id = #{id,jdbcType=INTEGER}
  </select>
  <insert id="insert" parameterType="com.hint.domain.Girl">insert into girl (id, girl_name, girl_birthday) values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{birthday,jdbcType=TIMESTAMP})</insert>
  </mapper>

5、配置
1)创建mybatis

2)配置

应该是 = 而不是 :
6、测试