How to configure multiple base packages for mapperconfigurer.
We tried giving comma separated/ semi colon to put multiple base packages.
@Bean
public MapperScannerConfigurer mapper1(Environment env)
throws Exception
{
MapperScannerConfigurer mapper = new MapperScannerConfigurer();
mapper.setBasePackage("co.test1.event.mapper1,co.test2.event.mapper2");
return mapper;
}
Please read the following Java doc I found in ConfigurableApplicationContext.java
/**
* Any number of these characters are considered delimiters between
* multiple context config paths in a single String value.
* @see org.springframework.context.support.AbstractXmlApplicationContext#setConfigLocation
* @see org.springframework.web.context.ContextLoader#CONFIG_LOCATION_PARAM
* @see org.springframework.web.servlet.FrameworkServlet#setContextConfigLocation
*/
String CONFIG_LOCATION_DELIMITERS = ",; \t\n";
The reason I brought this up is, I found the following line in MapperScannerConfigurer#postProcessBeanDefinitionRegistry
scanner.scan(StringUtils.tokenizeToStringArray(this.basePackage, ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS));
I think I made my point. ;-)
You should try below with annotations to configure multiple base packages:
@Configuration
@MapperScan({"com.transactions.persistence.mapper","com.transactions2.persistence.mapper"})
public class MyBatisConfig {
...
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With