1.在pom.xml配置文件添加以下依赖
<!--mybatis依赖-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.3.0</version>
</dependency>
2.在application.yml中添加以下配置
map-underscore-to-camel-case: true #将数据库表有下划线字段自动映射成小驼峰
type-aliases-package: com.example.springboot_mybatis.pojo #需要命别名的实体类所在的包全名
#配置mybatis
mybatis:
configuration:
map-underscore-to-camel-case: true
mapper-locations: classpath:/mapper/*.xml #resources/mapper/xxx.xml
type-aliases-package: com.example.springboot_mybatis.pojo
#以debug模式在后台打印sql语句
logging:
level:
com.example.springboot_mybatis: debug