문제 및 해결

[해결] Available parameters are [arg1, arg0, param1, param2 오류 _ myBatis

박성하하 2023. 7. 4. 10:05
728x90
반응형

문제 : 

booktitle은 못찾고 arg1, arg0, param1, param2만 사용할 수 있다..?

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'booktitle' not found. Available parameters are [arg1, arg0, param1, param2]
	org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)
	org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
	com.sun.proxy.$Proxy57.selectList(Unknown Source)
	org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230)
	org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:139)
	org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:76)
	org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
	com.sun.proxy.$Proxy61.getSpecificBookList(Unknown Source)
	com.joongang.service.BookService.getSpecificBookList(BookService.java:63)
	com.joongang.service.BookService$$FastClassBySpringCGLIB$$fe169e89.invoke(<generated>)
	org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
	org.springframework.aop.framework.CglibAopProxy.invokeMethod(CglibAopProxy.java:386)
	org.springframework.aop.framework.CglibAopProxy.access$000(CglibAopProxy.java:85)
	org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:704)
	com.joongang.service.BookService$$EnhancerBySpringCGLIB$$cd8c8bb2.getSpecificBookList(<generated>)
	com.joongang.controller.BookController.getSpecificBookList(BookController.java:72)
	java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.base/java.lang.reflect.Method.invoke(Method.java:566)
	org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
	org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
	org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
	org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:529)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:623)
	org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)

 

발생 원인

MyBatis를 이용한 SQL Mapper의 메소드는 하나의 파라미터만을 읽음.

즉, 파라미터의 개수가 2개 이상일 때 발생

 

해결

페이징 관리 클래스 criteria를 BookVO 안에 넣어서 mybatis쿼리로는 하나의 파라미터만 전송되도록 설정하니 해결되었다.

 

 

 

출처: https://m.blog.naver.com/hj_kim97/222739563456

 

[MyBatis]org.apache.ibatis.binding.BindingException: Parameter '파라미터명' not found. 에러

에러 내용 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.bindi...

blog.naver.com

 

728x90
반응형