构建 mybatis 程序遇到的错误

  1. 绑定异常

    org.apache.ibatis.binding.BindingException: Type interface com.alivin.dao.UserDao is not known to the MapperRegistry.

<!--每一个 Mapper.xml 都需要在 mybatis 核心配置文件中注册-->
  1. java.lang.ExceptionInInitializerError

    在build中配置 resource,来防止资源导出失败的问题

<!--maven的资源过滤问题-->
<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <includes>
                <include>**/*.properties</include>
                <include>**/*.xml</include>
            </includes>
            <filtering>false</filtering>
        </resource>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.properties</include>
                <include>**/*.xml</include>
            </includes>
            <filtering>false</filtering>
        </resource>
    </resources>
</build>
  • 可能遇到的问题

    • 配置文件没有注册
    • 绑定接口错误
    • 方法名不对
    • 返回类型不对
    • Maven 导出资源问题
posted @ 2021-06-02 16:38  -费费  阅读(49)  评论(0编辑  收藏  举报