Exception encountered during context initialization - cancelling refresh attempt: 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:\javaexercise\furn-ssm\target\classes\mapper\FurnMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'file [D:\javaexercise\furn-ssm\target\classes\mapper\FurnMapper.xml]'. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.ymt.furn.dao.FurnMapper.BaseResultMap
出现这样的报错,你往下拉还可以看到
ailed to parse mapping resource: 'file [D:\javaexercise\furn-ssm\target\classes\mapper\FurnMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'file [D:\javaexercise\furn-ssm\target\classes\mapper\FurnMapper.xml]'. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for
xml信息重复或具体是 Result Maps
集合中已经包含了一个值为 com.ymt.furn.dao.FurnMapper.BaseResultMap
的元素,这通常意味着 BaseResultMap
在 XML 文件中被重复定义了,或者在其他地方(可能是同一个 XML 文件或其他 Mapper XML 文件)被错误地引用了。
========原因是=========
一.你用逆向工程生成的xml文件内容重复导致的报错 正常生成的*.xml文件都是200多行,如果有500百行以上就是重复生成了,如果你一个个去对应的查id,可以查到很多重复的,你可以先去删除对应的xml文件后重新生成,要在你的逆向工程这段话中
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1:3306/furn_ssm?useSSL=true&useUnicode=true&characterEncoding=utf-8&rewriteBatchedStatements=true&autoCommit=true" userId="xxx" password="xxx"> </jdbcConnection>
二.加入这段话<property name="nullCatalogMeansCurrent" value="true" />防止重复
然后重新生成运行就可以了