MapperScannerConfigurer integrated with mybatis and spring

//Implements the BeanDefinitionRegistryPostProcessor and InitializingBean interfaces
// so first will call
/ / Empty scan package
public void afterPropertiesSet() throws Exception {
    notNull(this.basePackage, "Property 'basePackage' is required");
  }


//then call
 public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
    if (this.processPropertyPlaceHolders) {
      processPropertyPlaceHolders();
    }

    ClassPathMapperScanner scanner = new ClassPathMapperScanner(registry);
    scanner.setAddToConfig(this.addToConfig);
    scanner.setAnnotationClass(this.annotationClass);
    scanner.setMarkerInterface(this.markerInterface);
    scanner.setSqlSessionFactory(this.sqlSessionFactory);
    scanner.setSqlSessionTemplate(this.sqlSessionTemplate);
    scanner.setSqlSessionFactoryBeanName(this.sqlSessionFactoryBeanName);
    scanner.setSqlSessionTemplateBeanName(this.sqlSessionTemplateBeanName);
    scanner.setResourceLoader(this.applicationContext);
    scanner.setBeanNameGenerator(this.nameGenerator);
    scanner.registerFilters();
    //Scan and register BeanDefinition, it should be noted that the beanClass scanned and registered here is MapperFactoryBean. definition.setBeanClass(MapperFactoryBean.class);
    scanner.scan(StringUtils.tokenizeToStringArray(this.basePackage, ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS));
  }

 
 //final call
 public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
    // left intentionally blank
  }

  /** This class is to scan the package where the mapper is located, and then register it in the BeanDefinitionRegistry. Hand over to spring's finishBeanFactoryInitialization(beanFactory);
  method to load the bean. */



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326443114&siteId=291194637