警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [beans.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'class path resource [mybatis/mapper/UserMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'class path resource [mybatis/mapper/UserMapper.xml]'. Cause: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for mybatis.mapper.UserMapper.getUserList. please check mybatis/mapper/UserMapper.xml and class path resource [mybatis/mapper/UserMapper.xml]

 Error creating bean with name 'sqlSessionFactory' defined in class path resource [beans.xml]: Invocation of init method failed;

由这句可以看出来应该是xml文件中,id为sqlSessionFactory的bean出了问题

Failed to parse mapping resource: 'class path resource [mybatis/mapper/UserMapper.xml]';

由这句可以看出关联mybatis配置文件的时候出了问题

Cause: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for mybatis.mapper.UserMapper.getUserList. please check mybatis/mapper/UserMapper.xml and class path resource [mybatis/mapper/UserMapper.xml]

already contains说明已经存在

检查发现,在mybatis-config.xml中配置过一遍,所以报错,注释掉就好了

 

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐