Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: ‘file [C:\Users\82784\IdeaProjects\spring-study\spring-10-mybatis\target\classes\com\fj\dao\UserMapper.xml]’;
IllegalArgumentException: Mapped Statements collection already contains value for com.fj.dao.UserMapper.selectUser. please check com/fj/dao/UserMapper.xml and file [C:\Users\82784\IdeaProjects\spring-study\spring-10-mybatis\target\classes\com\fj\dao\UserMapper.xml]
这两个错误在我整合mybatis-spring时遇到了,整了很久还是没有解决,第二天突然发现我在UserMapper.xml和spring-dao.xml文件中都绑定了同一个UserMapper接口,所以才导致报错
UserMapper.xml中
<mappers>
<mapper class="com.fj.dao.UserMapper"/>
</mappers>
spring-dao.xml中
<!-- 绑定Mybatis配置文件 -->
<property name="configLocation" value="classpath:mybatis-config.xml"/>
<property name="mapperLocations" value="classpath:com/fj/dao/*.xml"/>