zl程序教程

您现在的位置是:首页 >  其他

当前栏目

MyBatis-Plus 使用xml文件

文件mybatisXML Plus 使用
2023-09-11 14:20:10 时间

原文链接:https://my.oschina.net/u/4157150/blog/4282150

mybatis plus使用mapper.xml文件注意事项。

步骤1 加载dao文件,即dao接口文件

加载方式1.在dao接口上增加mapper注解

@Mapper
public interface AuthFunctionRepo extends BaseRepository<AuthFunction> 

加载方式2.在启动类加扫描注解

@MapperScan(basePackages = {"com.yxl.smart.auth.repo"}) 
或者@MapperScan("com.yxl.smart.auth.repo")

两种方式配置一种即可。重复配置也不会报错。

步骤2 加载mapper.xml文件

在属性文件中指定xml文件路径。

mybatis-plus:
  mapper-locations: classpath:com/yxl/smart/auth/repo/*.xml

xml文件在resources文件夹内路径配置方式