|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mybatis.spring.mapper.MapperScannerConfigurer
public class MapperScannerConfigurer
BeanFactoryPostProcessor that searches recursively starting from a base package for interfaces
and registers them as MapperFactoryBean. Note that only interfaces with at least one method will
be registered; concrete classes will be ignored.
The basePackage property can contain more than one package name, separated by either
commas or semicolons.
This class supports filtering the mappers created by either specifying a marker interface or an
annotation. The annotationClass property specifies an annotation to search for. The
markerInterface property specifies a parent interface to search for. If both
properties are specified, mappers are added for interfaces that match either criteria.
By default, these two properties are null, so all interfaces in the given
basePackage are added as mappers.
This configurer is usually used with autowire enabled so all the beans it creates are
automatically autowired with the proper SqlSessionFactory or SqlSessionTemplate.
If there is more than one SqlSessionFactory in the application, however, autowiring
cannot be used. In this case you must explicitly specify either an SqlSessionFactory or
an SqlSessionTemplate to use.
Configuration sample:
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="org.mybatis.spring.sample.mapper" />
<!-- optional unless there are multiple session factories defined -->
<property name="sqlSessionFactory" value="sqlSessionFactory" />
</bean>
MapperFactoryBean| Constructor Summary | |
|---|---|
MapperScannerConfigurer()
|
|
| Method Summary | |
|---|---|
void |
afterPropertiesSet()
|
void |
postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
|
void |
setAddToConfig(boolean addToConfig)
|
void |
setAnnotationClass(Class<? extends Annotation> annotationClass)
|
void |
setBasePackage(String basePackage)
|
void |
setMarkerInterface(Class<?> superClass)
|
void |
setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory)
|
void |
setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MapperScannerConfigurer()
| Method Detail |
|---|
public void setBasePackage(String basePackage)
public void setAddToConfig(boolean addToConfig)
public void setAnnotationClass(Class<? extends Annotation> annotationClass)
public void setMarkerInterface(Class<?> superClass)
public void setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory)
public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate)
public void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanExceptionpublic void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
postProcessBeanFactory in interface org.springframework.beans.factory.config.BeanFactoryPostProcessor
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||