天天看點

Spring單元測試報錯Error creating bean with name 'sqlSessionFactory' defined in class path resource。。。。。

單元測試代碼如下:

Spring單元測試報錯Error creating bean with name 'sqlSessionFactory' defined in class path resource。。。。。

運作後控制台報錯

Caused by: 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 [D:\eclipse2019_jdk\2019xiangmu\television\target\classes\mapper\AdminMapper.xml]’; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is ‘file [D:\eclipse2019_jdk\2019xiangmu\television\target\classes\mapper\AdminMapper.xml]’. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.syn.television.dao.AdminMapper.BaseResultMap

而我的spring配置檔案是

Spring單元測試報錯Error creating bean with name 'sqlSessionFactory' defined in class path resource。。。。。

經過在網上搜尋,并借鑒了https://www.cnblogs.com/hfx123/p/9685721.html

Spring單元測試報錯Error creating bean with name 'sqlSessionFactory' defined in class path resource。。。。。

注釋掉,就運作成功了(具體原因我現在也不是太明白)

Spring單元測試報錯Error creating bean with name 'sqlSessionFactory' defined in class path resource。。。。。

也希望路過的大神,給出你們的了解。

下一篇: DCB結構