spring和mybatis 加载多数据库的问题
<import resource="ApplicationContext-service.xml"/>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="username" value="xxx"/>
<property name="password" value="xxx"/>
<property name="url" value="jdbc:mysql://xxx/x?useUnicode=true&characterEncoding=utf8"/>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.flf.mapper" />
<property name="sqlSessionTemplateBeanName" value="centerSqlSession" />
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean" name="cneterSqlSessionFactory">
<property name="dataSource" ref="dataSource"></property>
<property name="mapperLocations" value="classpath*:mybatis/*.xml"/>
<property name="configLocation" value="classpath:mybatis/config.xml"/>
</bean>
<bean name="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<!--center db end-->
<!--exdb-->
<bean id="dataSourceEx" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://xxx/x2?useUnicode=true&characterEncoding=utf8"/>
<property name="username" value="xx"/>
<property name="password" value="xxxx"/>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.flf.mapper"/>
<property name="sqlSessionTemplateBeanName" value="exSqlSessionFactory"/>
</bean>
<bean id="sqlSessionFactoryEx" class="org.mybatis.spring.SqlSessionFactoryBean" name="exSqlSessionFactory">
<property name="dataSource" ref="dataSourceEx"></property>
<property name="mapperLocations" value="classpath*:mybatis/*.xml"/>
<property name="configLocation" value="classpath:mybatis/config.xml"/>
</bean>
<bean id="transactionManagerEx" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSourceEx"/>
</bean>
配置两个数据库,按照搜索到的做法对配置文件进行了修改,但是在启动服务时候总是报错,请高手指教,也可以加我的qq:1723537119。