SSM 生成mapper中xml文件:未能解析映射資源:“文件嵌套異常


錯誤日記我就網上隨便找個貼着:

錯誤一:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [C:\Users\Administrator\workspace\ssm-crud\target\classes\mapper\EmployeeMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving JdbcType. Cause: java.lang.IllegalArgumentException: No enum constant org.apache.ibatis.type.JdbcType.com.go.crud.bean.Department

 

網上找了好多方法試過,發現都還是不行,有可能錯誤在以下幾個原因:

1.看看自己mapper下有沒有空的xml文件

2.仔細觀察mapper下的映射xml文件里的SQL語句有沒有寫錯

我再說說我自己的錯誤,我錯在寫返回類型和映射接口類的時候沒寫完整,所以到時程序出錯,看圖

錯誤二:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'main' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [C:\Users\Administrator\workspace\ssm-crud\target\classes\mapper\EmployeeMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving JdbcType. Cause: java.lang.IllegalArgumentException: No enum constant org.apache.ibatis.type.JdbcType.com.go.crud.bean.Department

第二個錯誤也是發現我加載spring-dao后綴名沒寫,如果spring文件前面還有文件夾一定要把它寫完整不然加載不了,下面來張圖

 

如果問題還沒有解決可以根據錯誤信息看看錯誤哪里加載不了,比如說我這個Sqlsessionfactory說裝載不了bean那肯定就是我的spring-dao獲取不到,還是后面還提示說,找不到我的SqlMapper接口和找不到返回類型,所以導致程序錯誤。

 

最后說一句細心真的很重要、

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM