Class ClassPathMapperScanner
java.lang.Object
org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
org.springframework.context.annotation.ClassPathBeanDefinitionScanner
org.mybatis.spring.mapper.ClassPathMapperScanner
- All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.ResourceLoaderAware, org.springframework.core.env.EnvironmentCapable
public class ClassPathMapperScanner
extends org.springframework.context.annotation.ClassPathBeanDefinitionScanner
A
ClassPathBeanDefinitionScanner that registers Mappers by basePackage, annotationClass, or
markerInterface. If an annotationClass and/or markerInterface is specified, only the
specified types will be searched (searching for all interfaces will be disabled).
This functionality was previously a private class of MapperScannerConfigurer, but was broken out in version
1.2.0.
- Since:
- 1.2.0
- Author:
- Hunter Presnall, Eduardo Macarron
- See Also:
-
Field Summary
Fields inherited from class org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
IGNORE_CLASSFORMAT_PROPERTY_NAME, logger -
Constructor Summary
ConstructorsConstructorDescriptionClassPathMapperScanner(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) Deprecated, for removal: This API element is subject to removal in a future version.ClassPathMapperScanner(org.springframework.beans.factory.support.BeanDefinitionRegistry registry, org.springframework.core.env.Environment environment) Instantiates a new class path mapper scanner. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancheckCandidate(String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition) Set<org.springframework.beans.factory.config.BeanDefinitionHolder> Calls the parent search that will search and register all the candidates.protected booleanisCandidateComponent(org.springframework.beans.factory.annotation.AnnotatedBeanDefinition beanDefinition) voidConfigures parent scanner to search for the right interfaces.voidsetAddToConfig(boolean addToConfig) Sets the adds the to config.voidsetAnnotationClass(Class<? extends Annotation> annotationClass) Sets the annotation class.voidsetDefaultScope(String defaultScope) Set the default scope of scanned mappers.voidsetExcludeFilters(List<org.springframework.core.type.filter.TypeFilter> excludeFilters) Sets the exclude filters.voidsetLazyInitialization(boolean lazyInitialization) Set whether enable lazy initialization for mapper bean.voidsetMapperFactoryBean(MapperFactoryBean<?> mapperFactoryBean) Deprecated, for removal: This API element is subject to removal in a future version.Since 2.0.1, Please use thesetMapperFactoryBeanClass(Class).voidsetMapperFactoryBeanClass(Class<? extends MapperFactoryBean> mapperFactoryBeanClass) Set theMapperFactoryBeanclass.voidsetMarkerInterface(Class<?> markerInterface) Sets the marker interface.voidsetPrintWarnLogIfNotFoundMappers(boolean printWarnLogIfNotFoundMappers) Set whether print warning log if not found mappers that matches conditions.voidsetSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory) Sets the sql session factory.voidsetSqlSessionFactoryBeanName(String sqlSessionFactoryBeanName) Sets the sql session factory bean name.voidsetSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) Sets the sql session template.voidsetSqlSessionTemplateBeanName(String sqlSessionTemplateBeanName) Sets the sql session template bean name.Methods inherited from class org.springframework.context.annotation.ClassPathBeanDefinitionScanner
getBeanDefinitionDefaults, getRegistry, isCompatible, postProcessBeanDefinition, registerBeanDefinition, scan, setAutowireCandidatePatterns, setBeanDefinitionDefaults, setBeanNameGenerator, setIncludeAnnotationConfig, setScopedProxyMode, setScopeMetadataResolverMethods inherited from class org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
addExcludeFilter, addIncludeFilter, clearCache, findCandidateComponents, getEnvironment, getMetadataReaderFactory, getResourceLoader, isCandidateComponent, registerDefaultFilters, resetFilters, resolveBasePackage, setEnvironment, setMetadataReaderFactory, setResourceLoader, setResourcePattern
-
Constructor Details
-
ClassPathMapperScanner
public ClassPathMapperScanner(org.springframework.beans.factory.support.BeanDefinitionRegistry registry, org.springframework.core.env.Environment environment) Instantiates a new class path mapper scanner.- Parameters:
registry- the registryenvironment- the environment
-
ClassPathMapperScanner
@Deprecated(since="3.0.4", forRemoval=true) public ClassPathMapperScanner(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) Deprecated, for removal: This API element is subject to removal in a future version.Please use theClassPathMapperScanner(BeanDefinitionRegistry, Environment).Instantiates a new class path mapper scanner.- Parameters:
registry- the registry
-
-
Method Details
-
setAddToConfig
public void setAddToConfig(boolean addToConfig) Sets the adds the to config.- Parameters:
addToConfig- the new adds the to config
-
setAnnotationClass
Sets the annotation class.- Parameters:
annotationClass- the new annotation class
-
setLazyInitialization
public void setLazyInitialization(boolean lazyInitialization) Set whether enable lazy initialization for mapper bean.Default is
false.- Parameters:
lazyInitialization- Set the @{code true} to enable- Since:
- 2.0.2
-
setPrintWarnLogIfNotFoundMappers
public void setPrintWarnLogIfNotFoundMappers(boolean printWarnLogIfNotFoundMappers) Set whether print warning log if not found mappers that matches conditions.Default is
true. Butfalsewhen running in native image.- Parameters:
printWarnLogIfNotFoundMappers- Set the @{code true} to print- Since:
- 3.0.1
-
setMarkerInterface
Sets the marker interface.- Parameters:
markerInterface- the new marker interface
-
setExcludeFilters
Sets the exclude filters.- Parameters:
excludeFilters- the new exclude filters
-
setSqlSessionFactory
public void setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory) Sets the sql session factory.- Parameters:
sqlSessionFactory- the new sql session factory
-
setSqlSessionTemplate
Sets the sql session template.- Parameters:
sqlSessionTemplate- the new sql session template
-
setSqlSessionTemplateBeanName
Sets the sql session template bean name.- Parameters:
sqlSessionTemplateBeanName- the new sql session template bean name
-
setSqlSessionFactoryBeanName
Sets the sql session factory bean name.- Parameters:
sqlSessionFactoryBeanName- the new sql session factory bean name
-
setMapperFactoryBean
@Deprecated(since="2.0.1", forRemoval=true) public void setMapperFactoryBean(MapperFactoryBean<?> mapperFactoryBean) Deprecated, for removal: This API element is subject to removal in a future version.Since 2.0.1, Please use thesetMapperFactoryBeanClass(Class).Sets the mapper factory bean.- Parameters:
mapperFactoryBean- the new mapper factory bean
-
setMapperFactoryBeanClass
Set theMapperFactoryBeanclass.- Parameters:
mapperFactoryBeanClass- theMapperFactoryBeanclass- Since:
- 2.0.1
-
setDefaultScope
Set the default scope of scanned mappers.Default is
null(equiv to singleton).- Parameters:
defaultScope- the scope- Since:
- 2.0.6
-
registerFilters
public void registerFilters()Configures parent scanner to search for the right interfaces. It can search for all interfaces or just for those that extends a markerInterface or/and those annotated with the annotationClass -
doScan
public Set<org.springframework.beans.factory.config.BeanDefinitionHolder> doScan(String... basePackages) Calls the parent search that will search and register all the candidates. Then the registered objects are post processed to set them as MapperFactoryBeans- Overrides:
doScanin classorg.springframework.context.annotation.ClassPathBeanDefinitionScanner
-
isCandidateComponent
protected boolean isCandidateComponent(org.springframework.beans.factory.annotation.AnnotatedBeanDefinition beanDefinition) - Overrides:
isCandidateComponentin classorg.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
-
checkCandidate
protected boolean checkCandidate(String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition) - Overrides:
checkCandidatein classorg.springframework.context.annotation.ClassPathBeanDefinitionScanner
-
ClassPathMapperScanner(BeanDefinitionRegistry, Environment).