如题:两种配置方式
springboot的配置文件 添加:
mybatis.configuration.mapUnderscoreToCamelCase=true 或
mybatis.configuration.map-underscore-to-camel-case=true(根据版本不同)
2.通过@configuration配置的方式
@Bean(name = "sqlSessionFactory")
public SqlSessionFactory sqlSessionFactoryBean() throws IOException {
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
bean.setDataSource(dataSource);
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
bean.setMapperLocations(resolver.getResources("classpath:/mapper//.xml"));
try {
//开启驼峰命名转换
bean.getObject().getConfiguration().setMapUnderscoreToCamelCase(true);
return bean.getObject();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
网友评论