Type interface com.pastor.mapper.CardMapper is not known to the MapperRegistry. 解决方法
出错环境 :
在MyBatis环境下以注解的方法来实现对MySQL数据库一对一的操作
解决方法 :
在MyBatisConfig.xml中给CardMapper接口注册
<mappers>
<mapper class="com.pastor.mapper.CardMapper" />
</mappers>
如果不把相对应的另外一个接口注册将会报以下错误
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.pastor.mapper.PersonMapper.selectById
### The error may exist in com/pastor/mapper/CardMapper.java (best guess)
### The error may involve com.pastor.mapper.CardMapper.selectAll
### The error occurred while handling results
### SQL: SELECT * FROM card
### Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.pastor.mapper.PersonMapper.selectById
解决方法 :
把所引用的接口都进行注册
<mappers>
<mapper class="com.pastor.mapper.CardMapper" />
<mapper class="com.pastor.mapper.PersonMapper" />
</mappers>