spring项目中,加载不同路径下的mapper文件配置
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<!-- 自动扫描mapping.xml文件 多个路径 配置list -->
<property name="mapperLocations">
<list>
<value>classpath*:com/xxx/mapper/*.xml</value>
<value>classpath*:com/xxx/mapper/other/*.xml</value>
</list>
</property>
</bean>
<!-- Spring自动扫描配置的dao包下的类 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- 扫描多个包路径时,用逗号隔开 -->
<property name="basePackage" value="com.xxx.mapper,com.xxx.xxx.mapper" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
4万+

被折叠的 条评论
为什么被折叠?



