mybatis之开启驼峰映射

如果出现sql查询有数据但映射到javabean值为null,先查看是否开启mybatis的驼峰映射的设置。

  1. 在.properties文件中添加:
mybatis.configuration.map-underscore-to-camel-case=true 
  1. 在mybatis的配置文件,如mybatis-config.xml中进行配置:
<configuration>
    <!-- 开启驼峰映射 ,为自定义的SQL语句服务-->
    <!--设置启用数据库字段下划线映射到java对象的驼峰式命名属性,默认为false-->  
    <settings>
      <setting name="mapUnderscoreToCamelCase" value="true"/>
    </settings>
 
</configuration>

猜你喜欢

转载自blog.csdn.net/Piqzem/article/details/88372808