记录一下Mybatis异常:Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception with message: Failed to parse mapping resource: 'file [C:\Users\yzy\Desktop\jk\banyue\target\classes\mapper\roleauthority\RoauMapper.xml]'

原因很简单,就是找不到与mapper对应的mapper.xml文件

解决办法有两个

方法一:mapper路径与mapper.xml路径保持一致

这样build后文件就会在一起被识别到,路径名要保持一致

方法二:

配置文件配置mapper.xml文件路径

例如yml配置文件下

mybatis-plus:
  mapper-locations: classpath*:mapper/*.xml
  type-aliases-package: com.banyue.backend.pojo
 

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐