为了更加容易掌握MybatisPlus的内容,需要先创建数据库,然后进行实际操作掌握
一、MybatisPlus demo
1、创建数据库
mybatis_plus
2、创建User表
CREATE TABLE USER ( id BIGINT(20)NOT NULL COMMENT '主键ID', NAME VARCHAR(30)NULL DEFAULT NULL COMMENT '姓名', age INT(11)NULL DEFAULT NULL COMMENT '年龄', email VARCHAR(50)NULL DEFAULT NULL COMMENT '邮箱', PRIMARY KEY (id) );
3、User表insert数据
INSERT INTO user (id, name, age, email)VALUES (1, 'Jone', 18, '[email protected]'), (2, 'Jack', 20, '[email protected]'), (3, 'Tom', 28, '[email protected]'), (4, 'Sandy', 21, '[email protected]'), (5, 'Billie', 24, '[email protected]');
4、在idea上创建一个springboot项目,需要引入下面的包
<!--mybatis-plus--> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.3.1</version> </dependency> <!--mysql依赖--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <!--lombok用来简化实体类--> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency>
5、在idea的application.properties中配置数据库信息
#mysql数据库连接 spring boot 2.0(内置jdbc5驱动) spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.url=jdbc:mysql://172.16.137.131:3306/mybatis_plus?characterEncoding=utf-8&useSSL=false spring.datasource.username=root spring.datasource.password=123456 spring boot 2.1及以上(内置jdbc8驱动) 注意:driver和url的变化 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.url=jdbc:mysql://172.16.137.131:3306/mybatis_plus?serverTimezone=GMT%2B8 spring.datasource.username=root spring.datasource.password=123456
标签:web,01,MybatisPlus,spring,baomidou,datasource,mysql,NULL,com From: https://www.cnblogs.com/frankruby/p/16716866.html