classpath和classpath*区别
classpath :仅搜索 第一个匹配的资源(按类路径顺序)下的mapper/下的所有xml
classpath*: 加载 所有资源(自身jar,以及所有依赖jar)下 mappper/目录的所有xml。 这种情况需要注意,可能会存在同名的xxMapper文件,会被覆盖
mybatis:
#mapper-locations: classpath*:/mapper/**/*Mapper.xml
mapper-locations: classpath:/mapper/**/*Mapper.xml
type-aliases-package: com.springboot.pojo
configuration:
map-underscore-to-camel-case: true
所以如果需要加载自身jar以外的mapper文件和dao。建议如下配置,使用classpath来加在自身(因为classpath只会按顺序加载第一个找到的资源,所以首先会加载自身所有mapper文件),其次额外从所有资源内加载指定的其他mapper文件
mybatis:
mapper-locations: classpath:/mapper/**/*Mapper.xml,classpath*:/A/AMapper.xml,classpath*:/B/BMapper.xml
type-aliases-package: com.springboot.pojo
configuration:
map-underscore-to-camel-case: true
浙公网安备 33010602011771号