报错org.apache.ibatis.binding.BindingException: Parameter 'xxxxx' not found.

Given the Parameter 'xxxx' not found the Available the Parameters are [0, 1, param1, param2 ....
1. error message
  when in use today mybatis query data, org.apache.ibatis.binding.BindingException appear: Parameter 'username' not found. Available parameters are [0, 1, param1, param2] problem.

Error message:

Text:

org.apache.ibatis.binding.BindingException: Parameter ‘username’ not found. Available parameters are [0, 1, param1, param2]
at org.apache.ibatis.binding.MapperMethod$ParamMap.get(MapperMethod.java:168)
at org.apache.ibatis.reflection.wrapper.MapWrapper.get(MapWrapper.java:45)
at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:122)
at org.apache.ibatis.executor.BaseExecutor.createCacheKey(BaseExecutor.java:212)
at org.apache.ibatis.executor.CachingExecutor.createCacheKey(CachingExecutor.java:139)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81)
1
2
3
4
5
6
7
8
2.产生原因
Literally, that Mybatis and no match to this parameter.

3. Solution
using annotations @Param ( "XXX") to complete.

1. When only one parameter, the method Mapper / Dao layer are annotated may not be used.
For example, when inserting data:

public void insertAdmin(String username);

2. Multiple parameters must be used when @Param ( "XXX") to indicate:
such as login authentication when:

public void insertAdmin(@Param(“username”)String username,@Param(“password”)String password);

At this point in the run no longer being given.

4. Summary
In dao interface method parameters preceded @param annotation scenario:

1. When only one parameter, the method dao interface can not annotate. Mybatis successfully matching parameters.
2. When more than one parameter, the method requires the use of an interface dao annotations @Param ( "XXX") is the name of the designated parameter Mybatis.

Also, if you want time to pass multiple parameters, or use the map incoming or add @Param comment

Reference blog: https://blog.csdn.net/csdn_am/article/details/79854107

Author: csdnzoutao
Source: CSDN
Original: https://blog.csdn.net/itbiggod/article/details/82705287
Copyright: This article is a blogger original article, reproduced, please attach Bowen link!

Guess you like

Origin blog.csdn.net/wcc178399/article/details/92560345