MyBatis is an excellent persistence layer framework. Although Spring Boot does not integrate MyBatis officially, the MyBatis team ADAPTS the corresponding launcher to further simplify the operation of data using MyBatis
Because of the convenience of Spring Boot framework development, it is very simple to realize the integration of Spring Boot and data access layer framework (such as MyBatis). It is mainly to introduce the corresponding dependent initiator and set the parameters related to the database
Basic environment construction:
1. Data preparation
In MySQL, a database, SpringBootData, is created, and then two tables, T_ARTICLE and T_COMMENT, are created and inserted into the tables. Where the a_id of the comment table T_comment is associated with the primary key ID of the article table T_article
CREATE DATABASE springbootData; USE springBootData; DROP TABLE IF EXISTS t_article; CREATE TABLE t_article (id int(20) NOT NULL AUTO_INCREMENT COMMENT 'id', Title varchar(200) DEFAULT NULL COMMENT '主 体 ', content longtext COMMENT' 主 体 ', PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; INSERT INTO T_article VALUES ('1', 'Spring Boot basics ', '... '); INSERT INTO T_article VALUES ('2', 'Spring Cloud basics ', '... '); DROP TABLE IF EXISTS t_comment; CREATE TABLE t_comment (id int(20) NOT NULL AUTO_INCREMENT COMMENT ' ', content longtext COMMENT ' ' ', Author varchar(200) DEFAULT NULL COMMENT '标 题 ', a_id int(20) DEFAULT NULL COMMENT' 标 题 ', PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; INSERT INTO T_comment VALUES ('1', 'luccy', '1'); INSERT INTO T_comment VALUES ('2', '1', 'Tom ', '1'); INSERT INTO T_comment VALUES ('3', '1', 'Eric ', '1'); INSERT INTO T_comment VALUES (' 2 ', '1', '1', '1'); INSERT INTO T_comment VALUES ('5', '5', '5', '2'); Just learned pull hook education "Java engineers high salary boot camp", see just learned point on the answer. I hope the pull check can push me to the company I want to go to, target: byte!!Copy the code