javaormibatismybatis

mybatis: Using mapper interfaces with XML config for global parameters


I like the XML notation for specifying global parameters such as connection strings. I also like Mapper annotations. When I try to combine the two, I get this exception.

Is there a way to combine the two? I would like to use an XML file for the global configurations, but have mybatis take Mapper interfaces into account.

The problem is that SqlSessionFactoryBuilder().build() takes either a Reader (which I want to use to pass the XML config), or a Configuration object (which I see has the addMappers() method that can help me) - but I don't understand how to combine the two.


Solution

  • factory.getConfiguration().addMapper(...);