springboot报错MyBatisSystemException:org.apache.ibatis.binding.BindingException的解决

springboot的服务端启动之后,用postman调用,发现返回失败。在control层捕获exception,打印为:nested exception is org.apache.ibatis.binding.BindingException:

完整报错如下:

SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5d7ded93] was not registered for synchronization because synchronization is not active
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5d7ded93]
Exception:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'phone' not found. Available parameters are [arg0, pwd, param1, param2]
 

查了不少资料发现是参数没有加指定的原因:

在usermapper.java文件里,找到该接口,在入参定义的前面加上@Param("phone")指定其参数名为phone

@Repository
public interface UserMapper {

    List<user> login(@Param("phone") String phone, @Param("pwd") String pwd);

    List<user> listUser();

}

 

在usermapper.xml文件里对于该接口,则采用#{phone,jdbcType=VARCHAR}的形式,就可以进行具名调度。

<select id="login" resultType="songbay.mes.project.domain.user">

    select * from user_info where phone = #{phone,jdbcType=VARCHAR} and pwd = #{pwd,jdbcType=VARCHAR}

</select>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值