content: package com.transaction.config;
  
  import org.springframework.boot.autoconfigure.AutoConfigureAfter;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import tk.mybatis.mapper.common.Mapper;
  import tk.mybatis.spring.mapper.MapperScannerConfigurer;
  
  import java.util.Properties;
  
  @Configuration
  @AutoConfigureAfter(MyBatisConfig.class)
  public class MyBatisMapperScannerConfig {
  
      @Bean
      public MapperScannerConfigurer mapperScannerConfigurer() {
          MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
          mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory");
          mapperScannerConfigurer.setBasePackage("com.transaction.mapper");
          Properties properties = new Properties();
          // 这里要特别注意，不要把MyMapper放到 basePackage 中，也就是不能同其他Mapper一样被扫描到。 
          properties.setProperty("mappers", Mapper.class.getName());
          properties.setProperty("notEmpty", "false");
          properties.setProperty("IDENTITY", "MYSQL");
          mapperScannerConfigurer.setProperties(properties);
          return mapperScannerConfigurer;
      }
  
  }
  