zoukankan      html  css  js  c++  java
  • mybatis中mapUnderscoreToCamelCase自动驼峰命名转换

    ssm项目中在mybatis配置文件中添加以下配置,可以将数据库中user_name转化成userName与实体类属性对应,如果数据库使用如user_name的命名方式,实体类采用驼峰命名。配置后无需写resultMapper将数据库字段和实体类属性对应

    1.  
      <?xml version="1.0" encoding="UTF-8" ?>
    2.  
      <!DOCTYPE configuration
    3.  
      PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
    4.  
      "http://mybatis.org/dtd/mybatis-3-config.dtd">
    5.  
      <configuration>
    6.  
      <settings>
    7.  
      <setting name="mapUnderscoreToCamelCase" value="true" />
    8.  
      </settings>
    9.  
      </configuration>


    在spring boot项目中没有mybatis.xml文件,配置文件application.properties中,加入配置项:

    1.  
      1 mybatis.configuration.mapUnderscoreToCamelCase=true
    2.  
      2 或
    3.  
      3 mybatis.configuration.map-underscore-to-camel-case=true

    设为true表示开启驼峰转换。经过试验,两种配置方法都可以。但如果同时配置,前者mybatis.configuration.mapUnderscoreToCamelCase的优先级更高
    --------------------- 本文来自 fangwenzheng88 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/fangwenzheng88/article/details/78469976?utm_source=copy 

  • 相关阅读:
    长宽广州地区DNS
    修改PHP的memory_limit限制
    适用于Magento的最合适的.htaccess写法
    在magento中如何回复客户的评论
    冲刺!
    冲刺!
    冲刺!
    冲刺!
    冲刺!
    冲刺!
  • 原文地址:https://www.cnblogs.com/jiftle/p/9700436.html
Copyright © 2011-2022 走看看