此文羅列Mybatis中配置mapper路徑的四種方式,如下圖:
注意:mapper配置中不能使用通配符*,mybatis不支持。
補充:關於通用匹配是spring提供的ant匹配法,mybatis 沒有這個功能。具體實現見:AntPathMatcher
正確例子:
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mapperLocations" value="classpath*:sample/config/mappers/**/*.xml" />
</bean>