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: 密码

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

相关推荐
青山木5 小时前
Hot 100 ---腐烂的橘子
java·数据结构·后端·算法·leetcode·广度优先
卷无止境5 小时前
Python的collections模块:那些被低估的"瑞士军刀"
后端·python
卷无止境5 小时前
Python的方法解析顺序:一场关于继承顺序的精妙设计
后端·python
ruleslol5 小时前
SpringBoot26-@Configuration + @Component
spring boot
宁&沉沦5 小时前
Chrome 扩展 Manifest 字段版本支持一览(全量)
前端·后端·编辑器
吃饱了得干活6 小时前
缓存与数据库一致性:从理论到实战
java·后端·面试
520拼好饭被践踏6 小时前
JAVA+Agent学习day22
java·开发语言·后端·学习
whi6 小时前
V 编译器 v3 ownership 模式:编译与使用指南
后端·编译器
swipe6 小时前
05|(前端转后全栈)不手写一堆 SQL,后端怎么操作数据库?MyBatis-Plus 入门
前端·后端·全栈
霸道流氓气质6 小时前
SpringBoot中使用JasperReports 报表引擎 — 介绍、原理与使用实践
java·spring boot·后端