|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mybatis.spring.annotation.MapperScannerPostProcessor
public class MapperScannerPostProcessor
BeanDefinitionRegistryPostProcessor that searches recursively
starting from a basePackage for interfaces with Mapper
annotation
and registers MapperFactoryBeans.
It is usually used with autowire enabled so all the beans it creates are
automatically autowired with the proper SqlSessionFactory
or
SqlSessionTemplate
It there is more than one DataSource or SqlSessionFactory
in the application
autowire cannot be used. In this case you can specify
SqlSessionFactory
or SqlSessionTemplate
to use.
When specifying any of these beans notice that bean names must be used instead of real references. It has to be this way because the MapperScannerPostProcessor runs very early in the Spring startup process and some other post processors have not started yet (like PropertyPlaceholderConfigurer) and if they are needed (for example to setup the DataSource) the start process will fail.
Configuration sample:
<bean class="org.mybatis.spring.annotation.MapperScannerPostProcessor">
<property name="basePackage" value="org.mybatis.spring.sample.mapper" />
<!-- optional, notice that "value" is used, not "ref" -->
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
</bean>
SqlSessionFactory
,
MapperFactoryBean
Constructor Summary | |
---|---|
MapperScannerPostProcessor()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
|
void |
postProcessBeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
|
void |
postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
|
void |
setAddToConfig(boolean addToConfig)
|
void |
setBasePackage(String basePackage)
|
void |
setSqlSessionFactoryBeanName(String sqlSessionFactoryName)
|
void |
setSqlSessionTemplateBeanName(String sqlSessionTemplateName)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MapperScannerPostProcessor()
Method Detail |
---|
public void setBasePackage(String basePackage)
public void setAddToConfig(boolean addToConfig)
public void setSqlSessionTemplateBeanName(String sqlSessionTemplateName)
public void setSqlSessionFactoryBeanName(String sqlSessionFactoryName)
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
Exception
public void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) throws org.springframework.beans.BeansException
postProcessBeanFactory
in interface org.springframework.beans.factory.config.BeanFactoryPostProcessor
org.springframework.beans.BeansException
public void postProcessBeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) throws org.springframework.beans.BeansException
postProcessBeanDefinitionRegistry
in interface org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
org.springframework.beans.BeansException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |