springboot 中mybatis 配置


1.导入

<dependency>
    <groupId>org.mybatis.spring.bootgroupId>
    <artifactId>mybatis-spring-boot-starterartifactId>
    <version>2.1.1version>
dependency>

2.配置

在application.yml中加入如下配置

debug: false
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    username: root
    password: 123456
    url: jdbc:mysql://127.0.0.1:3306/mall?characterEncoding=utf-8&useUnicode=true
mybatis:
  mapper-locations: classpath:mybatis/mapping/*.xml
  type-aliases-package: com.cj.pojo
  configuration:
    map-underscore-to-camel-case: true

3.驼峰命名

mybatis.configuration.map-underscore-to-camel-case: true