| | |
| | | package com.java110.db; |
| | | |
| | | import com.java110.db.MyBatisConfig; |
| | | import org.mybatis.spring.mapper.MapperScannerConfigurer; |
| | | import org.springframework.boot.autoconfigure.AutoConfigureAfter; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | /** |
| | | * MyBatis扫描接口 |
| | | * |
| | | * @author 吴学文 |
| | | * @since 2017-12-19 14:46 |
| | | */ |
| | | @Configuration |
| | | //TODO 注意,由于MapperScannerConfigurer执行的比较早,所以必须有下面的注解 |
| | | @AutoConfigureAfter(MyBatisConfig.class) |
| | | public class MyBatisMapperScannerConfig { |
| | | |
| | |
| | | public MapperScannerConfigurer mapperScannerConfigurer() { |
| | | MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer(); |
| | | mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory"); |
| | | mapperScannerConfigurer.setBasePackage("mapper"); |
| | | |
| | | // 关键修复:设置Mapper接口的实际包路径(多个包用逗号分隔) |
| | | // 替换为你实际的Mapper接口所在包(必须包含com.java110.job.dao) |
| | | mapperScannerConfigurer.setBasePackage("com.java110.job.dao,com.java110.fee.dao"); |
| | | |
| | | // 可选:指定注解扫描(只扫描带@Mapper的接口,更精准) |
| | | mapperScannerConfigurer.setAnnotationClass(org.apache.ibatis.annotations.Mapper.class); |
| | | |
| | | return mapperScannerConfigurer; |
| | | } |
| | | } |
| | | } |