使用springmvc+mybaties出现如下错误:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter ‘user_type’ not found. Available parameters are [2, 1, 0, param1, param2, param3]
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:368)
at com.sun.proxy.$Proxy37.selectOne(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:163)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43)
at com.sun.proxy.$Proxy41.getUserByPasswordAndType(Unknown Source)
at cn.piaole.mybatis.demo.core.service.impl.UserServiceImpl.register(UserServiceImpl.java:42)
at cn.piaole.mybatis.demo.action.RegisterAction.register(RegisterAction.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
原因:
[email protected],当只有一个参数时,Mapper中可以不使用
public User getUser(String name);
但是当你有多个参数时就必须使用
public User getUser(@Param("name") String name,@Param("password") String password);
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/11211.html