Mybatis 返回值 返回Map的为空的值


第一种、springMVC和boot通用配置:(Mybatis.xml)

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD SQL MAP Config 3.1//EN"

"http://mybatis.org/dtd/mybatis-3-config.dtd">

<configuration>

    <settings>

        <setting name="callSettersOnNulls" value="true"/>

    </settings>

</configuration>

第二种、boot专用配置:

在application.properties中添加:

mybatis.configuration.call-setters-on-nulls=true

第三种、每个sql返回字段做判断(通用boot、mvc、比较麻烦):

IFNULL(name,'') as name

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM