
1. 写了一个很简单查询全部数据的demo接口,结果一直返回null. 数据库明明有数据而且在console控制台也可以查到,但是用接口访问一直返回null
2.后发现原来是数据库中字段名和对象的属性名称对不上,所以可以在yml文件中加上
mybatis:
configuration:
map-underscore-to-camel-case: true
mapper-locations: classpath:mapper/*Mapper.xml
作者遇到一个Mybatis接口查询示例返回null的问题,经排查发现是由于数据库字段名与对象属性不匹配。通过在yml配置中启用`map-underscore-to-camel-case`解决了问题,即自动将下划线命名法转换为驼峰命名法。

1. 写了一个很简单查询全部数据的demo接口,结果一直返回null. 数据库明明有数据而且在console控制台也可以查到,但是用接口访问一直返回null
2.后发现原来是数据库中字段名和对象的属性名称对不上,所以可以在yml文件中加上
mybatis:
configuration:
map-underscore-to-camel-case: true
mapper-locations: classpath:mapper/*Mapper.xml
2201
1408
4567

被折叠的 条评论
为什么被折叠?