1.配置mapper接口所在包(dao)
package标签,通过name属性指定mapper接口所在的包名,此时对应的映射文件必须与接口位于同一路径下。
<mappers>
<package name="com.i.mapper"/>
<mappers>
2相对路径配置
<mappers>
<mapper resource="com/i/mapper/xxxmapper.xml"/>
<mappers>
3.类注册引入:
<mappers>
<mapper class="com.i.mapper.xxxmapper.xml"/>
<mappers>
4总结:
只有配置了mappers信息之后,Mybatis才知道去哪里加载Mapper映射文件。一般在mybatis-config.xml的配制文件中配置。