org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderExce

原创 2018年04月17日 16:53:07

使用mybaties的@SelectProvider时出现的问题

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error invoking SqlProvider method (com.example.demo.dynamicsql.SqlProvider.selectCandidate).  Cause: org.apache.ibatis.binding.BindingException: Parameter 'arg0' not found. Available parameters are [id, param1]

上面是抛出的异常,就是找不到参数,我首先要生成一个动态sql,id默认为0,如果id为0,就查出所有数据,即不拼接where条件,若id不为0就查处对应的一条数据。新建一个和dao文件夹同级的pakage,里面的代码如下


然后我的dao层,代码为

 @SelectProvider(type = SqlProvider.class, method = "selectCandidate")
    @Results(id="candidateMap",value={
            @Result(property="id", column="id"),
            @Result(property="job", column="job"),
            @Result(property="salary", column="salary"),
            @Result(property="interviewTime", column="interview_time"),
            @Result(property="channel", column="channel"),
            @Result(property="name", column="name"),
            @Result(property="sex", column="sex"),
            @Result(property="nativePlace", column="native_place"),
            @Result(property="edu", column="edu"),
            @Result(property="peoples", column="peoples"),
            @Result(property="birthday", column="birthday"),
            @Result(property="domicile", column="domicile"),
            @Result(property="marriage", column="marriage"),
            @Result(property="politicalStatus", column="political_status"),
            @Result(property="address", column="addtress"),
            @Result(property="workAge", column="work_age"),
            @Result(property="phone", column="phone"),
            @Result(property="contracts", column="contracts"),
            @Result(property="contactsPhone", column="contracts_phone"),
            @Result(property="email", column="email"),
            @Result(property="qq", column="qq"),
            @Result(property="education", column="education"),
            @Result(property="work", column="work"),
            @Result(property="certificate", column="certificate"),
            @Result(property="skill", column="skill"),
            @Result(property="state", column="state"),
    })
    List<Candidate> selectCandidate(@Param("id")Integer id);

然后当我在动态sql类SqlProvider里面打断点,就发现无论把断点打着函数的哪个位置,断点都进不来,我开始怀疑是不是我的动态sql使用姿势错了,https://www.cnblogs.com/he-px/p/7134524.html,查看了这篇博客,我发现前端即便是传一个参数,sql类函数的参数也是map,然后从map里面过去想要的条件参数,于是我把SqlProvider这里里面对应函数的参数改成map。


这样就可以,可是为什么para的大小是2呢,我们查看debug控制台


然后去Dao那一层,我们试着将@Param那个参数删掉,然后我SqlProvider还原到参数是integer的样子,结果成功解决

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorEx

情况:在实体类中写了一个构造函数,没有使用所有元素,然后使用select查询的时候,会返回如下错误信息 org.mybatis.spring.MyBatisSystemException: nes...
  • gao784xiao
  • gao784xiao
  • 2016-12-04 22:03:24
  • 2383

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.Reflecti...
  • chp891202
  • chp891202
  • 2016-12-26 15:19:04
  • 1623

Spring错误:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.B

使用springmvc+mybaties出现如下错误: org.mybatis.spring.MyBatisSystemException: nested exception is org.apac...
  • u014079773
  • u014079773
  • 2016-07-09 10:28:38
  • 3937

mybatis配置的一些小问题总结 mybatis报错:org.mybatis.spring.MyBatisSystemException: nested exception is org.apach

mybatis报错:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exception...
  • hcmony
  • hcmony
  • 2017-01-16 10:00:17
  • 3964

mybatis 异常 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingExce...
  • TimOut
  • TimOut
  • 2017-08-21 17:47:19
  • 489

MyBatis批量更新报错org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.bindin

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingExce...
  • myNameIssls
  • myNameIssls
  • 2017-01-05 11:53:27
  • 4162

nested exception is org.mybatis.spring.MyBatisSystemException

exception org.springframework.web.util.NestedServletException: Request processing failed; nested e...
  • csdnZCjava
  • csdnZCjava
  • 2017-07-16 13:15:34
  • 402

mybatis报错:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exception

接口配置: package mybatis.mapper; import java.util.List; public interface TestMapper { public List se...
  • u011214505
  • u011214505
  • 2016-07-28 11:40:41
  • 92945

Spring错误:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.Bi

今天再次使用spring+mybatis出现了下列的错误: 可以直接拉到底看解决方法 org.mybatis.spring.MyBatisSystemException: nested...
  • sinat_29325027
  • sinat_29325027
  • 2016-04-13 15:01:52
  • 35012

nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis

Type Exception Report Message Request processing failed; nested exception is org.mybatis.spring.MyB...
  • hc1017
  • hc1017
  • 2018-01-27 18:54:30
  • 129
收藏助手
不良信息举报
您举报文章:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderExce
举报原因:
原因补充:

(最多只允许输入30个字)