email
varchar(50) DEFAULT NULL COMMENT ‘邮箱’,
PRIMARY KEY (id
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
三、搭建工程
工程目录结构
1. 使用 Spring Initializer 初始化一个 Spring Boot 工程
需要引入项目所需要的依赖
pom.xml
<java.version>1.8</java.version>
org.springframework.boot
spring-boot-starter-parent
2.2.2.RELEASE
org.springframework.boot
spring-boot-starter
org.springframework.boot
spring-boot-starter-test
test
com.baomidou
mybatis-plus-boot-starter
3.0.5
mysql
mysql-connector-java
org.projectlombok
lombok
org.springframework.boot
spring-boot-maven-plugin
2. 在 application.properties配置文件中添加 数据库的相关配置
数据库配置
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/数据库名?serverTimezone=GMT%2B8
spring.datasource.username=root
spring.datasource.password=root
mybatis日志(控制台显示sql语句)
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
3. 配置 MapperScan 注解
在 Spring Boot 启动类中添加 @MapperScan 注解