@@ -338,53 +338,16 @@ mybatis-plus:
338
338
> Page 对象是继承 RowBounds,是 Mybatis 内置对象,无法在 mapper 里获取
339
339
> 请使用自定义 Map/对象,或者通过@Param("page") int page,size 来传参
340
340
341
- # # 开启查询结果【下划线转驼峰】
342
-
343
- > 该功能是 mybatis 原生自带,配置如下
344
-
345
- Spring Bean 配置:
346
-
347
- ` ` ` java
348
- MybatisConfiguration configuration = new MybatisConfiguration();
349
- configuration.setMapUnderscoreToCamelCase(true);//开启下划线转驼峰
350
- //...其他配置,见上面的【配置jdbcTypeForNull=NULL】
351
- ` ` `
352
-
353
- Spring Boot yml 配置:
354
-
355
- ` ` ` yaml
356
- mybatis-plus:
357
- configuration:
358
- map-underscore-to-camel-case: true
359
- ` ` `
360
-
361
341
# # 如何使用:【Map下划线自动转驼峰】
362
342
363
343
指的是:`resultType="java.util.Map"`
364
344
365
- - todo 注意事项待定,等待3.1.1版本发布后再写
366
-
367
- - Java Config Bean 方式
345
+ - spring boot
368
346
369
347
` ` ` java
370
- @Configuration
371
- @MapperScan("com.baomidou.mybatisplus.test.h2.entity.mapper")
372
- public class MybatisConfigMetaObjOptLockConfig {
373
-
374
- @Bean("mybatisSqlSession")
375
- public SqlSessionFactory sqlSessionFactory(DataSource dataSource, ResourceLoader resourceLoader, GlobalConfiguration globalConfiguration) throws Exception {
376
- MybatisSqlSessionFactoryBean sqlSessionFactory = new MybatisSqlSessionFactoryBean();
377
- MybatisConfiguration configuration = new MybatisConfiguration();
378
- configuration.setDefaultScriptingLanguage(MybatisXMLLanguageDriver.class);
379
- configuration.setJdbcTypeForNull(JdbcType.NULL);
380
- //*注册Map 下划线转驼峰*
381
- configuration.setObjectWrapperFactory(new MybatisMapWrapperFactory());
382
-
383
- sqlSessionFactory.setConfiguration(configuration);
384
- //...其他配置
385
- return sqlSessionFactory.getObject();
386
- }
387
- ...
348
+ @Bean
349
+ public ConfigurationCustomizer configurationCustomizer() {
350
+ return i -> i.setObjectWrapperFactory(new MybatisMapWrapperFactory());
388
351
}
389
352
` ` `
390
353
@@ -463,4 +426,4 @@ private Boolean status;
463
426
464
427
原因: dev-tools, 3.1.1+针对字段缓存,使用.class来作为key替换了原来的className, 而使用dev-tools会把.class使用不同的classLoader加载,导致可能出现找不到的情况
465
428
466
- 解决方案: 去掉dev-tools插件
429
+ 解决方案: 去掉dev-tools插件
0 commit comments