I am re factoring an existing application to spring3 and mybatis-spring.
One of my restrictions is to keep the current package layout.
it seems that when using org.mybatis.spring.mapper.MapperScannerConfigurer or <mybatis:scan> that is does not recursively look other packages, and i am looking how best to do this. I have it working now by adding individually each DAO interface to the MapperScannerConfigurer
in my applicationContext i have ::
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="formularyDb" />
<property name="configLocation" value="file:/web/sites/drugformulary-spring/config/mybatis-config.xml" />
<property name="mapperLocations" value="file:/web/sites/drugformulary-spring/mappers/*.xml" />
</bean>
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean>
<bean id="drugmasterScanner" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="org.mydm.formulary.drugmaster.dao
,org.mydm.formulary.pdfgroup.dao
,org.mydm.formulary.drugconfig.dao
"
/>
</bean>
As mentioned i have to add each of these interfaces eg:org.mydm.formulary.pdfgroup.dao manually.
I have tried <property name="basePackage" value="org.mydm.formulary "/> but none of the dao's where found and I also tried
<mybatis:scan base-package="org.myd.formulary.drugmaster" /> which also did not work, to work the package where the doa is must be specified.
my package structure is like below and i am required to keep it like this
org.mydm.formulary.drugmaster.controller
.service
.dao
org.mydm.formulary.pdfgroup.controller
.service
.dao
org.mydm.formulary.drugconfig.controller
.service
.dao