十二月 03, 2019 7:04:50 下午 org.springframework.context.support.AbstractApplicationContext refresh
警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring/applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [mybatis/SqlMapConfig.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.binding.BindingException: Type interface mapper.UserQueryMapper is already known to the MapperRegistry.
我这里引起的原因是:
<mappers>
<!--通过resource方法一次加载一个映射文件-->
<mapper resource="sqlmap/UserMapper.xml"></mapper>
<mapper resource="sqlmap/UserQueryMapper.xml"></mapper>
<!--批量加载Mapper-->
<package name="mapper"/>
</mappers>
处理方法是:
<mappers>
<!--通过resource方法一次加载一个映射文件-->
<mapper resource="sqlmap/UserMapper.xml"></mapper>
<mapper resource="sqlmap/UserQueryMapper.xml"></mapper>
<!--批量加载Mapper-->
否则mappe文件会重复使用相关接口造成错误。