Type interface is not known to the MapperRegistry.的解决办法
2016-12-06 15:50
253 查看
经验告诉我们这句错误是由于配置文件缺失配置导致的~~~
在mybatis中添加如下的配置即可:
<mappers>
<mapper resource="org/mybatis/builder/AuthorMapper.xml"/>
<mapper resource="org/mybatis/builder/BlogMapper.xml"/>
<mapper resource="org/mybatis/builder/PostMapper.xml"/>
</mappers>
还有可能就是:
延伸一下:
既然 MyBatis 的行为已经由上述元素配置完了,我们现在就要定义 SQL 映射语句了。但是首先我们需要告诉 MyBatis 到哪里去找到这些语句。 Java 在自动查找这方面没有提供一个很好的方法,所以最佳的方式是告诉 MyBatis 到哪里去找映射文件。你可以使用相对于类路径的资源引用, 或完全限定资源定位符(包括 file:/// 的
URL),或类名和包名等。例如:
上述方式1和2是XML定义,3和4则是注解定义
XML定义是常用的方式,用法如下:
<select id="testMyBatisWorks" resultType="java.util.HashMap">
<![CDATA[
{call pQueryAsyncNoticeList (
#{0,mode=IN,jdbcType=INTEGER}
)
}
]]>
</select>
注解则是:
/**
* 【proc列表】用存储过程查询得到列表
* @param asyncStatus
* @return
*/
@Select("exec pQueryAsyncNoticeList #{asyncStatus}")
@Options(statementType=StatementType.CALLABLE)
List<Map<String, Object>> getList2(int asyncStatus);
瞬间涨姿势了~~~吼吼吼
在mybatis中添加如下的配置即可:
<mappers>
<mapper resource="org/mybatis/builder/AuthorMapper.xml"/>
<mapper resource="org/mybatis/builder/BlogMapper.xml"/>
<mapper resource="org/mybatis/builder/PostMapper.xml"/>
</mappers>
还有可能就是:
延伸一下:
映射器(mappers)
既然 MyBatis 的行为已经由上述元素配置完了,我们现在就要定义 SQL 映射语句了。但是首先我们需要告诉 MyBatis 到哪里去找到这些语句。 Java 在自动查找这方面没有提供一个很好的方法,所以最佳的方式是告诉 MyBatis 到哪里去找映射文件。你可以使用相对于类路径的资源引用, 或完全限定资源定位符(包括 file:/// 的URL),或类名和包名等。例如:
<!-- Using classpath relative resources --> <mappers> <mapper resource="org/mybatis/builder/AuthorMapper.xml"/> <mapper resource="org/mybatis/builder/BlogMapper.xml"/> <mapper resource="org/mybatis/builder/PostMapper.xml"/> </mappers>
<!-- Using url fully qualified paths --> <mappers> <mapper url="file:///var/mappers/AuthorMapper.xml"/> <mapper url="file:///var/mappers/BlogMapper.xml"/> <mapper url="file:///var/mappers/PostMapper.xml"/> </mappers>
<!-- Using mapper interface classes --> <mappers> <mapper class="org.mybatis.builder.AuthorMapper"/> <mapper class="org.mybatis.builder.BlogMapper"/> <mapper class="org.mybatis.builder.PostMapper"/> </mappers>
<!-- Register all interfaces in a package as mappers --> <mappers> <package name="org.mybatis.builder"/> </mappers>
上述方式1和2是XML定义,3和4则是注解定义
XML定义是常用的方式,用法如下:
<select id="testMyBatisWorks" resultType="java.util.HashMap">
<![CDATA[
{call pQueryAsyncNoticeList (
#{0,mode=IN,jdbcType=INTEGER}
)
}
]]>
</select>
注解则是:
/**
* 【proc列表】用存储过程查询得到列表
* @param asyncStatus
* @return
*/
@Select("exec pQueryAsyncNoticeList #{asyncStatus}")
@Options(statementType=StatementType.CALLABLE)
List<Map<String, Object>> getList2(int asyncStatus);
瞬间涨姿势了~~~吼吼吼
相关文章推荐
- Type interface XXXMapper is not known to the MapperRegistry 解决办法
- Mybatis出现Type interface XXXMapper is not known to the MapperRegistry.的解决办法。
- Type interface com.mapper.GradeMapper is not known to the MapperRegistry的解决办法
- 解决org.apache.ibatis.binding.BindingException: Type interface xxx is not known to the MapperRegistry
- Type interface com.mybatis.mapper.UserMapper is not known to the MapperRegistry. 解决方法
- [练习][错误]MyBatis出错:Type interface com.dao.SubjectDao is not known to the MapperRegistry
- Type interface com.binarysoft.service.region.RegionDAO is not known to the MapperRegistry.
- FAQ(10):Type interface com.smbms.dao.UserMapper is not known to the MapperRegistry.
- Type interface mapper.UserMapper is not known to the MapperRegistry.
- Type interface com.hk.ssm.mapper.StudentMapper is not known to the MapperRegistry.
- Type interface mapper.XxxMapper is not known to the MapperRegistry.
- Type interface com.mybatis.mapper.StudentMapper is not known to the MapperRegistry
- Type interface com.zhaoka.mapper.DatKcardKmMapper is not known to the MapperRegistry
- Type interface com.xxx.xx.xxxDao is not known to the MapperRegistry
- Type interface cn.itsun.dao.UserDao is not known to the MapperRegistry.
- Type interface "xxxxxxxx" is not known to the MapperRegistry
- Type interface dxm.com.mapper.UserMapperI is already known to the MapperRegistry.
- Mybatis报错——Type interface com.mapper.EmployeeMapper is already known to the MapperRegistry.
- Mybatis注解学习--xxxMapper is not known to the MapperRegistry
- 解决办法:Access restriction: The type JPEGImageEncoder is not accessible due to restriction