MyBatis笔记:invalid bound statement (not found)

maven项目在本地运行的时候没有问题,一旦把war包部署到测试机上就不能运行。查看了一下tomcat日志发现抛出这样的错误:invalid bound statement (not found),后面是找不到某个Mapper类等等。

经提醒解压war包,发现WEB_INF/classes/dao/mapper下面根本没有包含相应的xml文件。修改pom.xml,在<build>结点里加入以下语句

<resources>
        <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
        </resource>
        <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
        </resource>
</resources>    

总之就是把要打包的文件类型都加进来。**/*.的写法是为了确保子文件夹下的内容也能打包。再部署之后就可以正常运行了。

时间: 2024-07-29 16:26:50

MyBatis笔记:invalid bound statement (not found)的相关文章

mybatis中Invalid bound statement (not found) 和 Result Maps collection already contains value for...错误解决方案

一.Invalid bound statement (not found) 使用mybatis有时候会报Invalid bound statement (not found)这种错误,总结了下,可能有两种情况如下: 1.mybatis的对应的mapper.xml找不到对应的命名sql或者名称与mapper接口名称不一致. 2.xml文件与接口名称都对,但是在mybatis配置文件中漏掉了配置,也会报这种错误. 二.Result Maps collection already contains v

解决Mybatis的invalid bound statement (not found)异常

使用Maven构建SSM时, 需要在pom.xml中配置一些信息, 否则mapper.xml就无法被扫描到, 程序就会抛invalid bound statement (not found)异常 解决办法: 将下面配置添加到pom.xml文件中 1 <build> 2 <resources> 3 <resource> 4 <directory>src/main/java</directory> 5 <includes> 6 <i

mybatis的Invalid bound statement (not found)

报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 解释:就是说,你的Mapper接口,被Spring注入后,却无法正常的使用mapper.xml的sql: 这里的Spring注入后的意思是,你的接口已经成功的被扫描到,但是当Spring尝试注入一个代理(MyBatista实现)的实现类后,却无法正常使用.这里的可能发生的情况有如下几种: 接口已经被扫描到,但是代理对象没有找到,即使

关于 Mybatis 的Invalid bound statement (not found):错误

今天遇到一个特别奇怪的问题,最后发现是自己对mybatis的学习还有待提高 返回类型可以用resultType,也可以用resultMap resultType是直接表示返回类型的,而resultMap则是对外部ResultMap的引用 举个例子: resultMap: <select id="findByContract" resultMap="BaseResultMap">        select        *        from    

idea的spring整合基于xml文件配置的mybatis报Invalid bound statement (not found): com.music.dao.MusicDao.findAll的问题

一. 题主当时就是自己尝试整合spring和mybatis的时候遇到了这个问题,当时题主只看到了用注解的方式配置的dao层,题主用的是xml文件配置的形式, 而且坑爹的是题主的两个文件的路径写的也不一致,就导致直接用<property name="basePackage" value="com.music.dao"></property> 导致绑定异常 后来在网上查到了解决的办法 ,就是如果路径一致,(如果一致你也就不会来看到本文了), 两个

mybatis plus Invalid bound statement (not found) 解决方案

常规的解决方案见:https://www.cnblogs.com/shaoyu/p/11477125.html 问题:当xml文件在src/main/java目录下时,在application.yml中配置Mapper文件路径无效,当xml文件在resource下时路径有效,原因不明. 我通过上面连接提到的所有的方法都无法解决遇到的问题.可能是mybatis plus的特殊性造成的,在参考其他人的解决方案的情况下, 终于解决了这个问题,解决方案如下: 重新在SqlSessionFactory中指

MyBatis笔记----报错Exception in thread &quot;main&quot; org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ij34.model.UserMapper.selectUser

信息: Refreshing org[email protected]41cf53f9: startup date [Wed Apr 05 16:48:12 CST 2017]; root of context hierarchy 四月 05, 2017 4:48:12 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definiti

MyBatis笔记----报错:Exception in thread &quot;main&quot; org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)解决方法

报错 Exception in thread "main" org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ij34.model.UserMapper.selectarticle at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:230) at or

关于mybatis Invalid bound statement (not found) 问题

初学mybatis   现在系统是spring + mybatis  applicationContext.xml里面配置了Mapper 自动扫描 <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">    <property name="basePackage" value="com.yolly.platform.*" /></bean&g