Class ClassPathMapperScanner

java.lang.Object
org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
org.springframework.context.annotation.ClassPathBeanDefinitionScanner
cn.lm.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:
  • Constructor Details

    • ClassPathMapperScanner

      public ClassPathMapperScanner(org.springframework.beans.factory.support.BeanDefinitionRegistry registry, org.springframework.core.env.Environment 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.
  • Method Details

    • setAddToConfig

      public void setAddToConfig(boolean addToConfig)
    • setAnnotationClass

      public void setAnnotationClass(Class<? extends Annotation> annotationClass)
    • 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. But false when running in native image.

      Parameters:
      printWarnLogIfNotFoundMappers - Set the @{code true} to print
      Since:
      3.0.1
    • setMarkerInterface

      public void setMarkerInterface(Class<?> markerInterface)
    • setExcludeFilters

      public void setExcludeFilters(List<org.springframework.core.type.filter.TypeFilter> excludeFilters)
    • setSqlSessionFactory

      public void setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory)
    • setSqlSessionTemplate

      public void setSqlSessionTemplate(org.mybatis.spring.SqlSessionTemplate sqlSessionTemplate)
    • setSqlSessionTemplateBeanName

      public void setSqlSessionTemplateBeanName(String sqlSessionTemplateBeanName)
    • setSqlSessionFactoryBeanName

      public void setSqlSessionFactoryBeanName(String sqlSessionFactoryBeanName)
    • setMapperFactoryBean

      @Deprecated public void setMapperFactoryBean(MapperFactoryBean<?> mapperFactoryBean)
      Deprecated.
      Since 2.0.1, Please use the setMapperFactoryBeanClass(Class).
    • setMapperFactoryBeanClass

      public void setMapperFactoryBeanClass(Class<? extends MapperFactoryBean> mapperFactoryBeanClass)
      Set the MapperFactoryBean class.
      Parameters:
      mapperFactoryBeanClass - the MapperFactoryBean class
      Since:
      2.0.1
    • setDefaultScope

      public void setDefaultScope(String defaultScope)
      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:
      doScan in class org.springframework.context.annotation.ClassPathBeanDefinitionScanner
    • isCandidateComponent

      protected boolean isCandidateComponent(org.springframework.beans.factory.annotation.AnnotatedBeanDefinition beanDefinition)
      Overrides:
      isCandidateComponent in class org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
    • checkCandidate

      protected boolean checkCandidate(String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition)
      Overrides:
      checkCandidate in class org.springframework.context.annotation.ClassPathBeanDefinitionScanner
    • getMapperHelper

      public MapperHelper getMapperHelper()
    • setMapperHelper

      public void setMapperHelper(MapperHelper mapperHelper)
    • setConfig

      public void setConfig(Config config)
      配置通用 Mapper
      Parameters:
      config -
    • setMapperHelperBeanName

      public void setMapperHelperBeanName(String mapperHelperBeanName)
    • setMapperProperties

      public void setMapperProperties(org.springframework.core.env.Environment environment)
      TODO 从环境变量中获取 mapper 配置信息
      Parameters:
      environment -
    • setMapperProperties

      public void setMapperProperties(String[] properties)
      TODO 从 properties 数组获取 mapper 配置信息
      Parameters:
      properties -