用JUnit測試Mybatis的BindingException異常

搭的Spring - Spring MVC - Mybatis項目,Web訪問正常,可是JUnit測試拋了以下異常:spring

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

原來是spring-mybatis配置文件中的節點須要把classpath改爲classpath*sql

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="mapperLocations" value="classpath:com/*/mapper/*.xml"></property>
</bean>

改爲classpath*以後,Debug as JUnit便可經過。apache

相關文章
相關標籤/搜索