public class R2dbcMapperScannerConfigurer extends Object implements org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.BeanNameAware
MapperFactoryBean. Note that only interfaces with at least one method will be registered;
concrete classes will be ignored.
This class was a {code BeanFactoryPostProcessor} until 1.0.1 version. It changed to
BeanDefinitionRegistryPostProcessor in 1.0.2. See https://jira.springsource.org/browse/SPR-8269 for the
details.
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 enables autowire for all the beans that it creates so that they are automatically autowired with the
proper ReactiveSqlSessionFactory or SqlSessionTemplate. If there is more than one ReactiveSqlSessionFactory
in the application, however, autowiring cannot be used. In this case you must explicitly specify either an
ReactiveSqlSessionFactory or an SqlSessionTemplate to use via the bean name properties. Bean names
are used rather than actual objects because Spring does not initialize property placeholders until after this class
is processed.
Passing in an actual object which may require placeholders (i.e. DB user password) will fail. Using bean names defers
actual object creation until later in the startup process, after all placeholder substitution is completed. However,
note that this configurer does support property placeholders of its own properties. The
basePackage and bean name properties all support ${property} style substitution.
copy from original MapperScannerConfigurer
R2dbcMapperFactoryBean,
ClassPathR2dbcMapperScanner| Constructor and Description |
|---|
R2dbcMapperScannerConfigurer() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
org.springframework.beans.factory.support.BeanNameGenerator |
getNameGenerator()
Gets beanNameGenerator to be used while running the scanner.
|
void |
postProcessBeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) |
void |
postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) |
void |
setAnnotationClass(Class<? extends Annotation> annotationClass)
This property specifies the annotation that the scanner will search for.
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setBasePackage(String basePackage)
This property lets you set the base package for your mapper interface files.
|
void |
setBeanName(String name) |
void |
setDefaultScope(String defaultScope)
Sets the default scope of scanned mappers.
|
void |
setLazyInitialization(String lazyInitialization)
Set whether enable lazy initialization for mapper bean.
|
void |
setMapperFactoryBeanClass(Class<? extends R2dbcMapperFactoryBean> mapperFactoryBeanClass)
The class of the
MapperFactoryBean to return a mybatis proxy as spring bean. |
void |
setMarkerInterface(Class<?> superClass)
This property specifies the parent that the scanner will search for.
|
void |
setNameGenerator(org.springframework.beans.factory.support.BeanNameGenerator nameGenerator)
Sets beanNameGenerator to be used while running the scanner.
|
void |
setProcessPropertyPlaceHolders(boolean processPropertyPlaceHolders)
Specifies a flag that whether execute a property placeholder processing or not.
|
void |
setSqlSessionFactoryBeanName(String sqlSessionFactoryName)
Specifies which
ReactiveSqlSessionFactory to use in the case that there is more than one in the spring context. |
public void setBasePackage(String basePackage)
You can set more than one package by using a semicolon or comma as a separator.
Mappers will be searched for recursively starting in the specified package(s).
basePackage - base package namepublic void setLazyInitialization(String lazyInitialization)
Default is false.
lazyInitialization - Set the @{code true} to enablepublic void setAnnotationClass(Class<? extends Annotation> annotationClass)
The scanner will register all interfaces in the base package that also have the specified annotation.
Note this can be combined with markerInterface.
annotationClass - annotation classpublic void setMarkerInterface(Class<?> superClass)
The scanner will register all interfaces in the base package that also have the specified interface class as a parent.
Note this can be combined with annotationClass.
superClass - parent classpublic void setSqlSessionFactoryBeanName(String sqlSessionFactoryName)
ReactiveSqlSessionFactory to use in the case that there is more than one in the spring context.
Usually this is only needed when you have more than one datasource.
Note bean names are used, not bean references. This is because the scanner loads early during the start process and it is too early to build mybatis object instances.
sqlSessionFactoryName - Bean name of the ReactiveSqlSessionFactorypublic void setProcessPropertyPlaceHolders(boolean processPropertyPlaceHolders)
The default is false. This means that a property placeholder processing does not execute.
processPropertyPlaceHolders - a flag that whether execute a property placeholder processing or notpublic void setMapperFactoryBeanClass(Class<? extends R2dbcMapperFactoryBean> mapperFactoryBeanClass)
MapperFactoryBean to return a mybatis proxy as spring bean.mapperFactoryBeanClass - The class of the MapperFactoryBeanpublic void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
setApplicationContext in interface org.springframework.context.ApplicationContextAwarepublic void setBeanName(String name)
setBeanName in interface org.springframework.beans.factory.BeanNameAwarepublic org.springframework.beans.factory.support.BeanNameGenerator getNameGenerator()
public void setNameGenerator(org.springframework.beans.factory.support.BeanNameGenerator nameGenerator)
nameGenerator - the beanNameGenerator to setpublic void setDefaultScope(String defaultScope)
Default is null (equiv to singleton).
defaultScope - the default scopepublic 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.BeanFactoryPostProcessorpublic void postProcessBeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
postProcessBeanDefinitionRegistry in interface org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessorCopyright © 2022. All rights reserved.