在SpringBoot中使用MyBatis 都是通過配置完成的
mybatis默認是屬性名和數據庫字段名一一對應的,即
數據庫表列:user_name
實體類屬性:user_name
但是java中一般使用駝峰命名
數據庫表列:user_name
實體類屬性:userName
Mapper.xml中的userName
在Springboot中,可以通過設置map-underscore-to-camel-case屬性為true來開啟駝峰功能。
application.yml中:
mybatis: mapper-locations: classpath:mapping/*Mapper.xml type-aliases-package: com.herbert.demo.entity configuration: map-underscore-to-camel-case: true cache-enabled: false