Springboot整合MyBatis(配置文件版)
程序员文章站
2022-07-12 22:50:50
...
官方文档:http://www.mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/
接口
application.yml
EmployeeMapper.xml
<?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="com.example.demomybatis.mapper.EmployeeMapper">
<!-- public Employee getEmpById(Integer id);
public void insertEmp(Employee employee);-->
<select id="getEmpById" resultType="com.example.demomybatis.bean.Employee">
SELECT * FROM employee WHERE id=#{id}
</select>
<insert id="insertEmp">
INSERT INTO employee(lastName,email,gender,d_id) VALUES (#{lastName},#{email},#{gender},#{dId})
</insert>
</mapper>
全局配置文件
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>
<settings>
<setting name="mapUnderscoreToCamelCase" value="true"/>
</settings>
</configuration>
添加数据
上一篇: C++中类的成员初始化问题
下一篇: 【STL源码分析】vector
推荐阅读
-
SpringBoot无废话入门04:MyBatis整合
-
springboot+springmvc+mybatis项目整合
-
SpringBoot 整合jdbc和mybatis
-
SpringBoot整合mybatis访问时报错Invalid bound statement (not found)
-
Spring boot Mybatis整合构建Rest服务(超细版)
-
SpringBoot整合Mybatis,SpringMVC简单例子
-
【SpringBoot】廿六、SpringBoot中整合MyBatis-Plus
-
SpringBoot系列(五)Mybatis整合完整详细版
-
SpringBoot+Mybatis+Durid整合多数据源的三种方式,第一种
-
如何利用IDEA搭建SpringBoot项目整合mybatis实现简单的登录功能