【SpringBoot】配置 MyBatis

2023-12-15 21:40:47
<!--    pom.xml    -->
<dependency>
    <groupId>org.mybatis.spring.boot</groupId>
    <artifactId>mybatis-spring-boot-starter</artifactId>
    <version>3.0.3</version>
</dependency>

<dependency>
    <groupId>com.mysql</groupId>
    <artifactId>mysql-connector-j</artifactId>
    <scope>runtime</scope>
</dependency>
# application.properties

spring.datasource.url=jdbc:mysql://localhost:3306/my_db
spring.datasource.username=root
spring.datasource.password=root
# 实现数据库下划线字段与实体中的驼峰属性映射
mybatis.configuration.map-underscore-to-camel-case=true
# application.yml
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql//localhost:3306/mybatis
    username: root
    password: root

文章来源:https://blog.csdn.net/XiugongHao/article/details/135024428
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。