package com.moral.config; import java.util.Properties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import com.moral.common.mapper.BaseMapper; import tk.mybatis.spring.mapper.MapperScannerConfigurer; @Configuration public class MapperScannerConfig { @Bean public MapperScannerConfigurer mapperScannerConfigurer() { MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer(); mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory"); mapperScannerConfigurer.setBasePackage("com.moral.mapper");//扫描该路径下的dao Properties properties = new Properties(); properties.setProperty("mappers", BaseMapper.class.getName());//通用dao properties.setProperty("notEmpty", "false"); properties.setProperty("IDENTITY", "MYSQL"); mapperScannerConfigurer.setProperties(properties); return mapperScannerConfigurer; } }