Mybatis中无效的比较: invalid comparison: java.util.Map and java.lang.String

出现以上情况基本是因为在标签中取值或者判断有问题,需要仔细检查,比如我出现的原因如下:

<if test='GroupConfig !=null and GroupConfig !='' and GroupConfig.appcode !=null and GroupConfig.appcode != '''>
${
    
    database}.device_${
    
    appcode}
</if>

出现以上情况的原因是,我传的参数GroupConfig是一个map集合,集合中有几个元素,在if标签中用GroupConfig !=’’ 这样判断肯定是不行的,就出现了Map转String出现类型不匹配的错误。

解决办法: 去掉and GroupConfig !=’’ 这个判断。

如果出现了类似 invalid comparison: java.util.xxx and java.util.xxx 这样的错误,要从标签中检查取值是否有问题。

猜你喜欢

转载自blog.csdn.net/m0_37899908/article/details/119791061
今日推荐