解决mybatis报错org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

解决mybatis报错org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

如果出现报错

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.nriat.core.system.dao.UserMapper.findByUserName] with root cause

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): xxx(com.nriat.core.system.dao.UserMapper.findByUserName这个是我自己的mapper方法,各人可能不同)

解决mybatis报错org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):_第1张图片

1.首先检查自己的mapper中是否有这个方法

解决mybatis报错org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):_第2张图片

2.检查对应的mapper中是否配置了对应的方法

解决mybatis报错org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):_第3张图片

3.检查xml的命名空间是否是有对应到mapper接口

解决mybatis报错org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):_第4张图片

4.如果以上三点检查了都没有问题,那么可以肯定,代码应该是没有问题的,那问题出现在哪呢?

检查一下target中的classes文件
解决mybatis报错org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):_第5张图片

这样一来,问题就找到了,那我们应该怎么解决呢?

解决办法:

在pom.xml中添加如下buid,目的就是让mapper文件在编译后也加入到classes文件中。

<build>
        <resources>
            <resource>
                <directory>src/main/javadirectory>
                
                <excludes>
                    <exclude>**/rebel.xmlexclude>
                excludes>
            resource>

            
            <resource>
                <directory>src/main/resourcesdirectory>
                <includes>
                    <include>**/*include>
                includes>
            resource>
        resources>
build>

最终结果

解决mybatis报错org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):_第6张图片

问题解决!!!

你可能感兴趣的:(报错解决,mybatis,java,maven,Exception,binding)