完整报错
org.apache.ibatis.exceptions.PersistenceException:
### Error building SqlSession.
### The error may exist in com.xxx/mapper/xxxMapper.xml
### The error occurred while processing mapper_resultMap[IdCardWithPersonResult2]_association[card]
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource com.xxx/mapper/xxxMapper.xml
虽然他说错误可能存在于xxxMapper.xml里面。
但是实际上可能存在于mybatis-config.xml配置文件里。
常常是因为里面的<mapper>里的路径写错。
比如,少写或多写或写错字母,或者/斜杠写成.点号了。
本例子中是因为斜杠写成了点号:
Could not find resource com.xxx/mapper/xxxMapper.xml
<mapper resource="com.xxx/mapper/xxxMapper.xml"/>
<mappers>
<mapper resource="com.xxx/mapper/xxxMapper.xml"/>
</mappers>
正确写法
<mapper resource="com/xxx/mapper/xxxMapper.xml"/>
要写.xml后缀。
<mappers>
<mapper resource="com/xxx/mapper/xxxMapper.xml"/>
</mappers>