Spring Boot简单xml配置mybatis

mybatis:
  type-aliases-package: com.xxx.xxx.pojo
  #config-location: classpath:mybatis/mybatis-config.xml
  mapper-locations: classpath:mapper/*.xml
  #Mybatis属性映射--开启驼峰命名
  configuration:
    map-underscore-to-camel-case: true
    jdbc-type-for-null: 'null'

设置为空的数据也可以入库

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
    <settings>
        <setting name="cacheEnabled" value="true"/>
        <setting name="logPrefix" value="dao."/>
        <!-- 新增时,对象为空也做新增,如果不配置则当mybatis接收到对象为null时,无法将其正确的进行解析 -->
        <setting name="jdbcTypeForNull" value="NULL" />
        <!-- 查询时,数据列为null也返回字段-->
        <setting name="callSettersOnNulls" value="true"/>
        <!-- 是否开启自动驼峰命名规则(camel case)映射,即从数据库列名 A_COLUMN 到属性名 aColumn 的类似映射 -->
        <setting name="mapUnderscoreToCamelCase" value="true"/>
    </settings>
</configuration>

猜你喜欢

转载自www.cnblogs.com/kkvt/p/12529109.html