This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Problem with multiple data sources in mybatis+spring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Problem with multiple data sources in mybatis+spring" Watch "Problem with multiple data sources in mybatis+spring" New topic

Problem with multiple data sources in mybatis+spring

chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Hi all, I am trying to configure 2 data sources in my project. I wrote thisWhen I try to execute a query it is giving me the following exceptionLater I came to know that the problem is with having multiple data sources. I removed the first data source and the associated sqlSessionFactory. Then I was able to run test case. If I include both then I am getting this error.

Can anyone please tell me how to fix this?

Love all, trust a few, do wrong to none.
Bill Gorder

Joined: Mar 07, 2010
Posts: 1682

I have not used myBatis (used it on a project back when it was iBatis) so I am not an expert but it looks like that error occurs when the below 3 names don't match, so your problem may not be a problem so much with multiple datasources but with the naming on one of them.

Verify this:

The three names that have to match:
- interface = xxx.yyy.zzz.mappers.SettingMapper.class
- mapper file = /xxx/yyy/zzz/mappers/SettingMapper.xml
- mapper namespace = xxx.yyy.zzz.mappers.SettingMapper

[How To Ask Questions][Read before you PM me]
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Problem with multiple data sources in mybatis+spring
It's not a secret anymore!