mybatis plus报Invalid bound statement (not found):解决

Mybatis-Plus

  • mybatis plus报Invalid bound statement (not found):解决
    • 未配置mapper扫描
      • 1、未扫描到mapepr接口,配置mapper扫描注解
      • 2、未编译mapper.xml文件,(查看class文件夹下面有没有)
      • 3、mapper.xml文件的namespace属性未配置正确
      • 4、application.yml文件配置扫描mapper.xml路径错误

mybatis plus报Invalid bound statement (not found):解决

你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果你想学习如何使用Markdown编辑器, 可以仔细阅读这篇文章,了解一下Markdown的基本语法知识。

未配置mapper扫描

1、未扫描到mapepr接口,配置mapper扫描注解

@MapperScan("com.baomidou.ant.sys.mapper")

2、未编译mapper.xml文件,(查看class文件夹下面有没有)

配置pom.xml

<build>
    <resources>
         <resource>
             <directory>src/main/javadirectory>
             <excludes>
                 <exclude>**/*.javaexclude>
             excludes>
         resource>
         <resource>
             <directory>src/main/resourcesdirectory>
             <includes>
                 <include>**/*.*include>
             includes>
        resource>
    resources>
build>

3、mapper.xml文件的namespace属性未配置正确

public interface DemoMapper extends BaseMapper<Demo> {
    Demo getDemoById(@Param("id")String id);
}

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baomidou.ant.sys.mapper.DemoMapper">
    <select id="getDemoById" parameterType="java.lang.String" resultType="com.baomidou.ant.sys.entity.Demo">
	   select * from demo
	   where id = #{id}
	</select>
</mapper>

4、application.yml文件配置扫描mapper.xml路径错误

mybatis:
  mapper-locations:
    classpath*:com/jdw/springboot/mapper/sqlxml/*.xml
  type-aliases-package: com.jdw.bean
  #  配置mybatis开启驼峰命名
  configuration:
    map-underscore-to-camel-case: true
    #打印mybatis所有SQL执行
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

你可能感兴趣的:(spring,boot)