IDEA下使用maven的mybatis常见错误(二)
错误类型二:mybatis.xml注册映射文件错误
- 错误提示:
Type interface com.aynu.dao.CountryDao is not known to the MapperRegistry
.
- 错误原因:mybatis.xml中注册映射文件的地方项目的目录写错了,其实原本应该写com.aynu.dao(即正确的dao包的所在目录)。
- 错误代码:
<mappers>
<package name="com.abc.dao"/>
</mappers>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!--为实体类指定别名-->
<typeAliases>
<package name="com.aynu.bean"/>
</typeAliases>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql:///employee"/>
<property name="username" value="root"/>
<property name="password" value="111"/>
</dataSource>
</environment>
</environments>
<!--注册映射文件-->
<mappers>
<package name="com.aynu.dao"/>
</mappers>
</configuration>