文章目录编写:HorinJsor
- 前言
- 一、使用步骤
- 1.新建项目(Spring Initializr方式)
- 2.选择依赖
- 3.完善依赖文件
- 4.配置文件application.yaml
- 总结
前言
本文介绍基础的SpringBoot框架搭建
提示:以下是本篇文章正文内容,下面案例可供参考
一、使用步骤 1.新建项目(Spring Initializr方式)在新建项目中选中如图所示内容:
2.选择依赖
根据实际要求选择。
3.完善依赖文件
图一中,若截图中报红,添加上方项目版本即可解决问题。
完整pom文件:
4.0.0 org.springframework.boot spring-boot-starter-parent 2.6.7 com.example TheToken 0.0.1-SNAPSHOT TheToken TheToken 1.8 org.springframework.boot spring-boot-starter-web org.projectlombok lombok true org.springframework.boot spring-boot-devtools org.springframework.boot spring-boot-starter-test test org.mybatis.spring.boot mybatis-spring-boot-starter 2.2.0 org.springframework.boot spring-boot-starter-jdbc mysql mysql-connector-java runtime org.springframework.boot spring-boot-maven-plugin 2.6.7 org.projectlombok lombok
4.配置文件application.yaml
图一中,若截图中报红,添加上方项目版本即可解决问题。
mybatis:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.domain
spring:
datasource:
url: jdbc:mysql://localhost:3306/数据库名
username: 数据库账号
password: "数据库密码"
driver-class-name: com.mysql.cj.jdbc.Driver
server:
port: 9092
servlet:
context-path: /路径名
总结
最后自行写上Controller测试,就可以开始使用了!



