1.确认sql语句拼接的没有问题
在配置文件mybatis-config.xml中进行配置
<settings>
<setting name= "mapUnderscoreToCamelCase" value = "true"/>
<setting name="logImpl" value="STDOUT_LOGGING" />
</settings>
如图,在控制台中查看最终执行的sql语句
2.确认数据库连接的字符编码
如果没有设置utf-8编码,会导致查询中文字段时,出现查询不到结果的问题。我这里就是这个问题
<property name="url" value="jdbc:mysql:///db1?useSSL=false&useUnicode=true&characterEncoding=utf8"/>