1. 程式人生 > >SSM 生成mapper中xml檔案:未能解析對映資源:“檔案巢狀異常

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介面和找不到返回型別,所以導致程式錯誤。

 

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