扫描mapper.xml文件问题

@MapperScan(basePackages = {“com.cybertron.barcode.service.dao”“})//扫描mapper.java和mapper.xml文件。

如果Mapper.xml与Mapper.class在同一个包下且同名,spring扫描Mapper.class的同时会自动扫描同名的Mapper.xml并装配到Mapper.class。

如果Mapper.xml与Mapper.class不在同一个包下或者不同名,就必须使用配置mapperLocations指定mapper.xml的位置。
application.yml中配置mybatis:
扫描mapper.xml文件问题_第1张图片
此时spring是通过识别mapper.xml中的 namespace的值来确定对应的Mapper.class的

你可能感兴趣的:(笔记)