今天发布生产环境后,进行验证时系统一直报”Mapped Statements collection does not contain value for“的错误,根据经验把常见的原因都查了一遍后,问题始终没有解决。就在一筹莫展的时候,突然想到mapper文件之前从一级目录挪到二级目录下,同时为了保证spring能扫描到二级目录下的mapper文件,把applicationContext.xml中关于mybatis扫描设置进行了修改,将:
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mapperLocations" value="classpath:mybatis/*/*.xml" />
</bean>
改为:
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mapperLocations" value="classpath:mybatis/**/*.xml" />
</bean>
最后,重启服务器,问题解决!