I initialized my SqlSessionFactory in java code using an environment and datasource defined within the java code as below:
TransactionFactory trxFactory = new JdbcTransactionFactory();
Environment env = new Environment("development", trxFactory, dataSource);
Configuration config = new Configuration(env);
config.setJdbcTypeForNull(JdbcType.NULL);
TypeAliasRegistry aliases = config.getTypeAliasRegistry();
aliases.registerAlias("XXXAttempt", XXXAttemptDao.class);
config.addMapper(XXXAttemptMapper.class);
SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(config);
my problem is that I need to add my xml mappers here but I couldn't: I tried to use:
config.addMappers("config/mybatis/xxx/*.xml");
and
config.addMappers("config/mybatis/xxx/*.xml");
with no luck. note that config.addMapper accepts only java class
The only way that worked is to move the xml file to the same package like the interface example to (REFERENCE):
config/com/example/mappers/XXXAttemptMapper.xml
but what I need is to be consistent with other projects and put the xml file in the below path:
config/myBatis/myDb/XXXAttemptMapper.xml
how to add the path for my xml file in the above location?
SqlSessionFactoryBeanprovided by mybatis-spring.