我是靠谱客的博主 标致咖啡豆,这篇文章主要介绍Springboot整合mybatis,配置驼峰命名转换(例:userId --user_id),现在分享给大家,希望可以做个参考。

如题:两种配置方式

1.

springboot的配置文件 添加:

mybatis.configuration.mapUnderscoreToCamelCase=true 或

mybatis.configuration.map-underscore-to-camel-case=true(根据版本不同)

2.通过@configuration配置的方式

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
@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); } }

 

最后

以上就是标致咖啡豆最近收集整理的关于Springboot整合mybatis,配置驼峰命名转换(例:userId --user_id)的全部内容,更多相关Springboot整合mybatis,配置驼峰命名转换(例:userId内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(73)

评论列表共有 0 条评论

立即
投稿
返回
顶部