自建网站工具,wordpress 并发量,网站基础功能,杭州优化外包公司排名在项目中经常会用到 mybatis 相关的一些配置#xff0c;而在启动类项目工程中#xff0c;一般会把 mybatis 配置文件单独写到 mybatis,yml 中#xff0c;如下简单介绍下常用的 mybatis 配置 mybatis:configuration:call-setters-on-nulls: truemap-underscore-to-camel-case… 在项目中经常会用到 mybatis 相关的一些配置而在启动类项目工程中一般会把 mybatis 配置文件单独写到 mybatis,yml 中如下简单介绍下常用的 mybatis 配置 mybatis:configuration:call-setters-on-nulls: truemap-underscore-to-camel-case: truemapperLocations: classpath*:mybatis/*.xml,classpath*:mapper/*.xml,classpath*:mybatis/mapping/**/*.xml,mybatis/base/*.xml1、mybatis.configuration.call-setters-on-nulls: true 当查询结果中的字段值为 null 时是否调用实体类对应属性的 setter 方法。设置为 true 时即使字段值为 null也会调用 setter 方法
2、mybatis.configuration.map-underscore-to-camel-case: true 将数据库字段名的下划线风格如 user_name映射为 Java 实体类的驼峰命名风格如 userName。设置为 true 时MyBatis 会自动进行这种映射
3、mybatis.mapperLocations 指定了 MyBatis 映射文件Mapper XML 文件的路径。多个路径之间用逗号分隔支持通配符 * 和 **。具体路径说明如下
classpath*:mybatis/*.xml扫描 classpath 下 mybatis 目录中的所有 .xml 文件
classpath*:mapper/*.xml扫描 classpath 下 mapper 目录中的所有 .xml 文件
classpath*:mybatis/mapping/**/*.xml扫描 classpath 下 mybatis/mapping 目录及其子目录中的所有 .xml 文件
mybatis/base/*.xml扫描 mybatis/base 目录中的所有 .xml 文件