springboot 配置mybatis报错[Request processing failed; nested exception is org.apache.ibatis.binding.Bind

一般情况下报下面这种错的几种原因

[Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

1.对于maven项目pom.xml文件中没有把sql配置文件作为资源文件引入,导致找不到sql,解决办法,在pom.xml文件的build节点下添加如下配置


    
        ${basedir}/src/main/resources
        
            **/*.yml
        
    
      
        ${basedir}/src/main/resources 
          
            **/*.properties 
          
    
    
        ${basedir}/src/main/resources
        
            **/*.xml
        
    
    
        ${basedir}/src/main/java
        
            **/*.xml
        
    

以上的 resources节点是build的直接子节点,位置不要错了

 

2.sql mapper.xml中配置的sql语句 id与接口 mapper中的方法名不一样,特别是大小写错误,单词拼写错误等,要保证一个sql在xml中配置的id属性与接口文件中的一个方法名是相同的,这样才能匹配找到。

 

你可能感兴趣的:(java)