1、实例化Configuration对象并将其mapUnderscoreToCamelCase属性设为true
public class WrapAndChangeConfigureSqlSessionFactory extends SqlSessionFactoryBean {
@Override
public void afterPropertiesSet() throws Exception {
super.afterPropertiesSet();
SqlSessionFactory sqlSessionFactory = super.getObject();
Configuration configuration = sqlSessionFactory.getConfiguration();
configuration.setMapUnderscoreToCamelCase(true);
}
}
2、在spring boot的配置文件application.properties中,加入配置项:
1 mybatis.configuration.mapUnderscoreToCamelCase=true 2 或 3 mybatis.configuration.map-underscore-to-camel-case=true
参考: https://www.cnblogs.com/zhangdong92/p/6986653.html