0

For config tow datasource, I config tow MapperScannerConfigurer in my .xml:

<bean id="hybirdMapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
            <property name="basePackage" value="com.XXX.A.hymapper" />
            <property name="sqlSessionFactoryBeanName" value="hybirdSqlSessionFactory"/>
</bean>
<bean id="mysqlMapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
            <property name="basePackage" value="com.XXX.B.mysmapper" />
            <property name="sqlSessionFactoryBeanName" value="mysqlSessionFactory"/>
</bean>
<bean id="mysqlSessionFactory" name="mysqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="mysqlDataSource" />
        <property name="configLocation" value="classpath:mybatis-config.xml" />
</bean>
<bean id="hybirdSqlSessionFactory" name="hybirdSqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="hybirdDataSource" />
        <property name="configLocation" value="classpath:mybatis-config.xml" />
</bean>

But when I run my app, error comes out: enter image description here So I find the source code about sqlSessionTemplateBeanName in MapperScannerConfigurer, and it shows: enter image description here

It seems that my usage is not wrong, so what can I do to sovle this problem when config multi datasource with xml file and where is my mistake? thx~

qi lu
  • 21
  • 1
  • Don't put screenshots of the code into the question. Copy and paste text instead. It is not easy to copy the class name from the screenshot for reference, images are not indexed etc – Roman-Stop RU aggression in UA Dec 27 '18 at 11:16
  • The error suggests that autowiring is used for `SqlSessionFactory` but the configuration you've showed specifies `sqlSessionFactoryBeanName`s explicitly. Can you enable and show us debug logging for `org.mybatis.spring.mapper.ClassPathMapperScanner` to see what actually happens in `org.mybatis.spring.mapper.ClassPathMapperScanner.processBeanDefinitions`. – Roman-Stop RU aggression in UA Dec 27 '18 at 11:24

0 Answers0