正文:

    <!-- 当有多个数据源时, 自sqlSessionFactory, mapperScannerConfigurer 到 transactionmanager, 都要设置两套id -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.rockbb.facility.common.dao.mapper, com.rockbb.facility.weixin.dao.mapper" />
        <!-- 当只有一个数据源时,这行可以不写. -->
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
    </bean>

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSourceLocal" />
        <property name="mapperLocations">
            <list>
                <value>classpath:com/rockbb/facility/common/dao/mapper/*.xml</value>
                <value>classpath:com/rockbb/facility/weixin/dao/mapper/*.xml</value>
            </list>
        </property>
    </bean>

其实后面发现可以用通配符*号。。。

参考博客:

多个mapper location时, mybatis spring的自动扫描配置 - Milton - 博客园
https://www.cnblogs.com/milton/p/4497355.html

相关文章:

  • 2022-12-23
  • 2021-11-08
  • 2021-09-29
  • 2021-06-02
  • 2022-12-23
  • 2021-09-16
  • 2022-12-23
  • 2021-09-20
猜你喜欢
  • 2021-10-23
  • 2022-02-16
  • 2021-07-26
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案