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

使用Springmvc+Mybatis时,增加了一个方法,然后报以下错误:(最下方解决方案)


2016-09-02 09:23:46,741 ERROR [500.jsp] - nested exception is org.apache.ibatis.binding.BindingException: Parameter 'schoolYear' not found. Available parameters are [3, 2, 1, 0, param1, param2, param3, param4]
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'schoolYear' not found. Available parameters are [3, 2, 1, 0, param1, param2, param3, param4]
	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)
	at com.sun.proxy.$Proxy21.selectList(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:198)
	at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119)
	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
	at com.sun.proxy.$Proxy78.getSSCG(Unknown Source)
	at com.jeeplus.modules.res.service.SchoolCurriculumService.getSSCG(SchoolCurriculumService.java:65)
	at com.jeeplus.modules.res.service.SchoolCurriculumService$$FastClassBySpringCGLIB$$4b1fe0a1.invoke()
	





	...  more

其实是忘了使用@Param,当只有一个参数时,Mapper中可以不使用

public List getSSCG(String schoolYear, String semester, String course, String grade);


但是当你有多个参数时就必须使用(改成一下就可以使用了)
public List getSSCG(@Param("schoolYear") String schoolYear, @Param("semester") String semester, @Param("course") String course, @Param("grade") String grade);


你可能感兴趣的:(Java,Mybatis)