Server/Spring
Invalid bound statement error 해결
selfstarter
2019. 7. 10. 15:53
error message
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): mapper pakage
Issue
- BaseMapper에 bean 등록을 하고 mapper를 통해서 쿼리문을 날려 원하는 값을 가져오는 예제를 실행시킴.
- 그런데 자꾸 Invalid bound statement 에러가 뜸
code
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { com.base.server.comm.config.RootConfig.class })
public class selectTest {
@Setter(onMethod\_ = @Autowired)
private BaseMapper mapper;
@Test
public void test() throws Exception {
System.out.println(mapper.selectIndex());
}
cause
- xml과 interface의 파일명이 달랐다
- @MapperScan의 interface 위치가 틀렸다
- xml과 interface의 위치가 동일하지 않았다(예를들어 com.base.test.mapper에 interface가 있다면 xml 파일도 resources/base/test/mapper/에 있어야 한다. 그리고 절대 폴더를 패키지 처럼 만들지 않는다)
solved
- 파일명과 위치를 동일하게 맞췄더니 해결되었다.