org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题解决

@[TOC](org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题解决)

开发框架说明

springboot2.2.7.RELEASE+ MyBatisPlus3.1.1

程序结构

在这里插入图片描述

问题描述

编译并启动springboot项目后,发起一个http请求http://localhost:8088/tbPpRfidstock/selectInfo,控制台报org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误,详细如下:

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.wongoing.sys.mapper.TbPpRfidstockMapper.getWareHouseInfoMap
	at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:235)
	at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.<init>(MybatisMapperMethod.java:49)
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.lambda$cachedMapperMethod$0(MybatisMapperProxy.java:66)
	at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.cachedMapperMethod(MybatisMapperProxy.java:66)
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:61)
	at com.sun.proxy.$Proxy77.getWareHouseInfoMap(Unknown Source)
	at com.wongoing.sys.controller.TbPpRfidstockController.selectInfo(TbPpRfidstockController.java:50)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)

问题分析

发现在编译后的target输出的类包目录中没有xml的Mapper文件

问题解决

修改pom.xml,增加对.xml文件的资源包含

	 <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
        </resources>
	</build>

先maven面板中clean一下,再重新编译运行,问题解决。

已标记关键词 清除标记
0.问题说明: 我是一名菜鸟,最近使用spring-mvc ,spring,mybatis框架 这两天出现一个错误一直搞不定,心好累,恳请前辈帮帮忙 1. 异常 ``` org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.misscandy.inter.UserMapper.findAllUsers org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868) javax.servlet.http.HttpServlet.service(HttpServlet.java:647) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) javax.servlet.http.HttpServlet.service(HttpServlet.java:728) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ``` 2.我的配置文件 ``` <!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="mapperLocations" value="classpath:com/misscandy/mapper/*.xml" /> </bean> <!-- 按指定包和注解扫描 Mapper/DAO --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="sqlSessionFactory" ref="sqlSessionFactory" /> <property name="basePackage" value="com.misscandy.inter" /> <property name="annotationClass" value="com.misscandy.mapper.Mapper" /> </bean> ``` 3.接口 UserMapper.java ``` package com.misscandy.inter; import java.util.Vector; import com.misscandy.entity.User; import com.misscandy.mapper.Mapper; @Mapper public interface UserMapper { void addUser(User user); //void deleteUser(User user); //void updateDept(User user); User findUserByName(String userName); Vector<User> findAllUsers(); //List<Map<String, Object>> findValue(); //List<DeptVO> findValues(); } ``` 4.UserMapper.xml ``` <?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"> <!-- namespace --> <mapper namespace="com.misscandy.inter.UserMapper"> <!-- @1 resultMap @2 resultMap=""--> <resultMap id="userResultMap" type="com.misscandy.entity.User"> <id property="userId" column="user_id" javaType="Integer" jdbcType="INTEGER" /> <result property="userName" column="user_name" javaType="String" jdbcType="VARCHAR" /> <result property="password" column="password" javaType="String" jdbcType="VARCHAR" /> <result property="sex" column="sex" javaType="Integer" jdbcType="INTEGER" /> <result property="age" column="age" javaType="Integer" jdbcType="INTEGER" /> <result property="type" column="type" javaType="Integer" jdbcType="INTEGER" /> <result property="lastLoginTime" column="last_login_time" javaType="Date" jdbcType="DATE" /> <result property="imageSrc" column="image_src" javaType="String" jdbcType="VARCHAR" /> </resultMap> <select id="findUserByName" parameterType="String" resultMap="userResultMap"> <![CDATA[ select user_id,user_name,image_src,age,sex,type from users where user_name = #{userName} ]]> </select> <select id="findAllUsers" resultMap="userResultMap"> <![CDATA[ select user_id,user_name,age,sex,type from users ]]> </select> <insert id="addUser" parameterType="com.misscandy.entity.User"> <![CDATA[ insert into users (user_name,password,sex,age,type) values (#{userName},#{password},#{sex},#{age},1) ]]> </insert> </mapper> ```
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页