Spring整合Mybatis如何使用xml文件配置sql语句

在使用MyBatis的时候由一个主配置文件,和多个映射文件(配置sql语句),在主配置文件里面需要使用标签加载映射文件
那么在整合之后写的映射文件需要加载吗?如果需要在哪里加载呢?

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">      
    <!--  可以是任意 的 DataSource,其配置应该和其它 Spring 数据库连接是一样的。-->      
    <property name="dataSource" ref="dataSource" />     
    <!-- 自动扫描entity目录, 省掉Configuration.xml里的手工配置 -->        
     <property name="mapperLocations" value="classpath*:mapper/*.xml" />     
</bean>

<!--    扫描的路径   -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">        
    <property name="basePackage" value="com.taste.clound.dao" />        
    <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" /> 
</bean>

```要有一个链条在心里 数据库在spring中配成DataSource 然后DataSource给mybatis的config 由config 生产sqlmapSessiong,再由sqlsession产生session进而连接操作数据库然后关闭。
你说的主配置文件一定要知道你配置的mapper,xml 在那里要不然怎么注入。

类似这样

<!-- 配置Mapper扫描 -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <!-- 设置Mapper扫描包 -->
        <property name="basePackage" value="com.xx.xx.mapper" />
    </bean>


<!-- 注入数据库连接池 -->

<!-- 配置MyBaties全局配置文件:mybatis-config.xml -->

<!-- 扫描entity包 使用别名 -->

<!-- 扫描sql配置文件:mapper需要的xml文件 -->此处就是配置映射文件的扫描