springboot配置mybatis

引入依赖

配置pom.xml文件,以MySQL为例,版本自行调节,刷新Maven

java 复制代码
<!--MySQL驱动依赖        -->
<dependency>
    <groupId>com.mysql</groupId>
    <artifactId>mysql-connector-j</artifactId>
</dependency>
<!--mybatis的起步依赖        -->
<dependency>
    <groupId>org.mybatis.spring.boot</groupId>
    <artifactId>mybatis-spring-boot-starter</artifactId>
    <version>3.0.0</version>
</dependency>

yml配置文件

配置MySQL的相关信息

java 复制代码
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:端口号/数据库名
    username: 用户名
    password: 密码

接下来就可以开始写接口啥的了

相关推荐
fox_lht1 小时前
15.3.改进我们之前的输入、输出项目
开发语言·后端·学习·rust
大鸡腿同学1 小时前
用 AI 肝了一个星期的智能客服助手,看看怎么个事
后端
IT_陈寒1 小时前
Python的os.path.join居然能这么坑?
前端·人工智能·后端
张忠琳2 小时前
【Go 1.26.4】Golang Channel 深度解析
开发语言·后端·golang
Rain5092 小时前
2.1 Nest.js 项目初始化与模块化架构
开发语言·前端·javascript·后端·架构·数据分析·node.js
cjp5602 小时前
009. ASP.NET WEB API 用户关联esp32设备
前端·后端·asp.net
贺国亚2 小时前
Text-to-SQL与Analytics-Agent
后端
一只叫煤球的猫2 小时前
ThreadForge 源码解读二:一个 Task 从 submit 到完成,内部到底发生了什么?
java·后端·面试
就叫_这个吧3 小时前
IDEA Mybatis xml文件,实现sql语句联想,自动填入补充
xml·mysql·intellij-idea·mybatis