一. 添加依赖
1. 创建SpringBoot的web工程:https://blog.csdn.net/Archer__13/article/details/126806516
2. 添加依赖
<!-- mybatis-plus启动器 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.1</version>
</dependency>
<!-- lombok用于简化实体类开发 -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- mysql驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!-- Thymeleaf -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
二. 配置application.yml文件
server:
port: 8080 #设置端口号
servlet:
context-path: / #设置访问应用的上下文路径
spring:
datasource: #配置连接数据库的信息
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
username: root
password: 123456
thymeleaf: #配置thymeleaf模板
cache: false #在开发阶段,关闭模板引擎
encoding: UTF-8 #编码格式
mode: HTML #模板的类型(默认是HTML)
prefix: classpath:/templates/ #模板前缀:文件的路径
suffix: .html #模板后缀
mvc:
static-path-pattern: /static/** #配置静态资源路径
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #添加日志
map-underscore-to-camel-case: true #在映射实体或属性时,将数据库中表名和字段名中的下划线去掉,按照驼峰命名法映射