@Service
public class TestServiceImpl implements TestService {
	@Override 
    public void testMethod(){
    	// ...
    }
}

 

위와 같이 @Repository 가 아닌 @Service로 등록했음에도 불구하고 Invalid bound statement 로 뜨면서 쿼리문을 못찾는다고 나옴

 

 

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.chris1108.mysite.service.TestService.testMethod
	at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:214)
	at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:48)

 

원인은 datasource-context.xml 에 설정했던 MapperScanner 때문 

@Repository 가 등록된 클래스들의 패키지를 확실하게 정하지 않은 상태여서 

실제 repository 들이 있는 com.chris1108.mysite.repository 가 아닌 

상위 패키지(com.chris1108.mysite ) 를 적었더니 해당 패키지에 위치한 @Service 까지도 mapper로 인식해 버리는 문제가 있었음. 

	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
	  	<property name="basePackage" value="com.chris1108.mysite" />
	</bean>

아래와 같이 변경 후 해결 

	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
	  	<property name="basePackage" value="com.chris1108.mysite.repository" />
	</bean>

+ Recent posts