異常:java
Exception in thread "main" org.apache.ibatis.binding.BindingException: Type interface com.yihaomen.mybatis.inter.IUserOperation is not known to the MapperRegistry.
at org.apache.ibatis.binding.MapperRegistry.getMapper(MapperRegistry.java:42)
at org.apache.ibatis.session.Configuration.getMapper(Configuration.java:655)
at org.apache.ibatis.session.defaults.DefaultSqlSession.getMapper(DefaultSqlSession.java:218)
at com.yihaomen.test.Test.main(Test.java:33)數據庫
緣由:User.xml 文件中 mapper中:錯誤以下紅色字體爲錯誤命名空間,接口編程中應對應接口所在路徑 ,綠色爲正確配置。apache
<--------?xml version="1.0" encoding="UTF-8" ?>
<--------!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<--------!--namespace="com.yihaomen.mybatis.inter.IUserOperation" -->
<--------mapper namespace="com.yihaomen.mybatis.models.UserMapper" >
<--------select id="selectUserByID" parameterType="int" resultType="User">
select * from `user` where id = #{id}
<--------/select>
<--------/mapper>編程