轉自:https://www.jianshu.com/p/bf2c129e2866
springboot項目中使用mybatis
pom文件中增加starter
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.2</version>
</dependency>
啟動類上,增加@MapperSacen注解
@MapperScan("com.example.mapper")
在com.example.mapper包下編寫Mapper接口
可以通過設置以下屬性,完成數據庫中表字段(下划線)和java bean(駝峰)的映射。
mybatis.configuration.map-underscore-to-camel-case=true