mybatis报错 Invalid bound statement (not found)

mybatis报错 Invalid bound statement (not found)

第一步:查看接口mapper和对应的xml文件的id是否一致

第二步:是由于maven默认加载机制造成

maven默认只会把src-main-java文件夹中的java类型文件进行加载,其他类型的文件不会加载

解决方式

通过配置文件进行配置,让maven默认加载xml

  • 在pom.xml中进行配置

        
        
            
                
                    src/main/java
                    
                        **/*.xml
                    
                    false
                
            
        
    
  • 在application.yml配置

    mybatis-plus:
      # classpath指的是生成的target里classes下的路径 
      mapper-locations: classpath:com/atguigu/eduservice/mapper/xml/*.xml
    

你可能感兴趣的:(mybatis报错 Invalid bound statement (not found))