org.springframework.core.NestedIOException: Failed to parse mapping resource: ‘file [XXX.xml]‘;

老规矩,先贴一下网上常见的解决方法

1、检查路径是否错误:

2、拼写的sql语句是否有问题:方法名是否等于id?

看看后台输出的sql语句是否正确

select * from register_user or company_name like #{companyName} or user_name like #{userName}

3、如果没有错误,那么去目录搜索这个文件,应该有重复的,删掉target目录下的重复文件,

只保留一个目录的文件即可,然后clear 清空缓存再运行

而我的问题在第四点,错误信息的后面,写着

Could not resolve type alias 'org.mybatis.caches.ehcache.LoggingEhcache'.  Cause: java.lang.ClassNotFoundException: Cannot find class: org.mybatis.caches.ehcache.LoggingEhcache
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586)

看样子问题出在这个看起二级缓存没有关闭上,去xml文件把代码注释掉:

org.springframework.core.NestedIOException: Failed to parse mapping resource: ‘file [XXX.xml]‘;
然后去代码生成的模板里把这个删除
org.springframework.core.NestedIOException: Failed to parse mapping resource: ‘file [XXX.xml]‘;
或者把enableCache设置为false
org.springframework.core.NestedIOException: Failed to parse mapping resource: ‘file [XXX.xml]‘;

上一篇:Ehcache(01)——简介、基本操作


下一篇:Ehcache(02)——ehcache.xml简介