Mybatis报错解决[不定时更新]

1、jdbcType=“int"和jdbcType=”_int"的区别

<resultMap id="Application" type="org.bean.Application">
        <constructor>
            <idArg column="id" javaType="_int"/>
            <arg column="project_id" javaType="_int"/>
            <arg column="name" javaType="string"/>
            <arg column="description" javaType="string"/>
            <arg column="deleted" javaType="_int"/>
        </constructor>
</resultMap>
public class Application {
    private int id;
    private int projectId;
    private String name;
    private int deleted;

    public Application(int id, int projectId, String name, String description, int deleted) {
        this.id = id;
        this.projectId = projectId;
        this.name = name;
        this.description = description;
        this.deleted = deleted;
    }
}

上面代码中mybatis的jdbcType=“int"须和Application中Integer类型对应,jdbcType=”_int"需和Application中int类型对应,任何一方不对应都会报java.lang.NoSuchMethodException: com.common.bean.Application.(int, int, java.lang.String, java.lang.String, int)错误。

2、报错:
The error may involve defaultParameterMap.
The error occurred while setting parameters.
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure.
解决:我出现的原因是在写mybatis的mapper文件时在sql语句后面用/**/写了注释,删掉就好了。
原来:<select id="retrieveAll" resultMap="Event"> select * from event_definition /*where type='HD'*/ </select>
改成:<select id="retrieveAll" resultMap="Event"> select * from event_definition </select>就成功了。
还有一个解决方案,我在网上找到的,将jdbc:mysql://127.0.0.1:3306/hr?useUnicode=true&characterEncoding=UTF-8&useSSL=false中的useSSL=false配置去掉也能成功。
注:我用的mysql是8.0.11版本,mybatis是3.5.0版本。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值