ssm 出现 Method threw 'org.apache.ibatis.binding.BindingException' exception.Invalid bound statement (not found)……

运行数据库的增删改查时出现 500状态码 并且提示 Method threw ‘org.apache.ibatis.binding.BindingException‘ exception.Invalid bound statement (not found),

后来才知道,IDEA的打包时默认不将 xml配置文件打包进去?毕竟在ssm中,SQL语句都是在配置文件中实现的,如果没打包进去怎么运行得起来。

dao层的pom.xml 如下:

  1 <?xml version="1.0" encoding="UTF-8"?>
  2
  3 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5     <parent>
  6         <artifactId>common-parent</artifactId>
  7         <groupId>com.example.edu</groupId>
  8         <version>1.0-SNAPSHOT</version>
  9     </parent>
 10     <modelVersion>4.0.0</modelVersion>
 11
 12     <artifactId>edu-dao</artifactId>
 13     <packaging>jar</packaging>   <!--希望打包成jar包-->
 14
 15     <name>edu-dao</name>
 16     <!-- FIXME change it to the project‘s website -->
 17     <url>http://www.example.com</url>
 18
 19     <properties>
 20         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 21         <maven.compiler.source>1.7</maven.compiler.source>
 22         <maven.compiler.target>1.7</maven.compiler.target>
 23     </properties>
 24
 25     <dependencies>
 26
 27         <dependency>
 28             <groupId>junit</groupId>
 29             <artifactId>junit</artifactId>
 30             <version>4.11</version>
 31             <scope>test</scope>
 32         </dependency>
 33
 34
 35         <dependency>
 36             <!--依赖model-->
 37             <!--那么问题来了,dao这里依赖model的作用是什么呢?-->
 38             <artifactId>edu-model</artifactId>
 39             <groupId>com.example.edu</groupId>
 40             <version>1.0-SNAPSHOT</version>
 41         </dependency>
 42
 43         <!--导入mybatis的jar包-->
 44
 45         <dependency>
 46             <groupId>org.mybatis</groupId>
 47             <artifactId>mybatis</artifactId>
 48             <version>${mybatis.version}</version>
 49         </dependency>
 50
 51
 52         <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
 53         <!--数据库驱动-->
 54         <dependency>
 55             <groupId>mysql</groupId>
 56             <artifactId>mysql-connector-java</artifactId>
 57             <version>${mysql.version}</version>
 58         </dependency>
 59
 60
 61     </dependencies>
 62
 63     <build>
 64
 65         <!--以下增加的内容可以在idea直接构建时就将xml文件一起打包 此时是需要依赖jstl -->
 66         <resources>
 67             <resource>
 68                 <directory>src/main/java</directory>
 69                 <includes>
 70                     <include>**/*.xml</include>
 71                 </includes>
 72             </resource>
 73         </resources>
 74
 75         <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
 76             <plugins>
 77                 <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
 78                 <plugin>
 79                     <artifactId>maven-clean-plugin</artifactId>
 80                     <version>3.1.0</version>
 81                 </plugin>
 82                 <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
 83                 <plugin>
 84                     <artifactId>maven-resources-plugin</artifactId>
 85                     <version>3.0.2</version>
 86
 87
 88                     <!--解决手动mvn时没将xml文件包括入内的问题-->
 89                     <!-- <executions>
 90                          <execution>
 91                              <id>copy-xmls</id>
 92                              <phase>process-sources</phase>
 93                              <goals>
 94                                  <goal>copy-resources</goal>
 95                              </goals>
 96                              <configuration>
 97                                  <outputDirectory>${basedir}/target/classes</outputDirectory>
 98                                  <resources>
 99                                      <resource>
100                                          <directory>${basedir}/src/main/java</directory>
101                                          <includes>
102                                              <include>**/*.xml</include>
103                                          </includes>
104                                      </resource>
105                                  </resources>
106                              </configuration>
107                          </execution>
108                      </executions>-->
109
110                 </plugin>
111                 <plugin>
112                     <artifactId>maven-compiler-plugin</artifactId>
113                     <version>3.8.0</version>
114                 </plugin>
115                 <plugin>
116                     <artifactId>maven-surefire-plugin</artifactId>
117                     <version>2.22.1</version>
118                 </plugin>
119                 <plugin>
120                     <artifactId>maven-jar-plugin</artifactId>
121                     <version>3.0.2</version>
122                 </plugin>
123                 <plugin>
124                     <artifactId>maven-install-plugin</artifactId>
125                     <version>2.5.2</version>
126                 </plugin>
127                 <plugin>
128                     <artifactId>maven-deploy-plugin</artifactId>
129                     <version>2.8.2</version>
130                 </plugin>
131                 <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
132                 <plugin>
133                     <artifactId>maven-site-plugin</artifactId>
134                     <version>3.7.1</version>
135                 </plugin>
136                 <plugin>
137                     <artifactId>maven-project-info-reports-plugin</artifactId>
138                     <version>3.0.0</version>
139                 </plugin>
140             </plugins>
141         </pluginManagement>
142     </build>
143 </project>

注意看66-73行间的代码,加上这部分后每次运行时idea会自动将xml配置文件打包进来

后面的88-108间的代码也可以解决这个问题,不过它每次都要你手动mvn insatll 来打包,当xml有改变时如果不手动打包的话就用不了了。

ssm 出现 Method threw 'org.apache.ibatis.binding.BindingException' exception.Invalid bound statement (not found)……

原文地址:https://www.cnblogs.com/Guhongying/p/10693434.html

时间: 2024-08-02 22:41:49

ssm 出现 Method threw 'org.apache.ibatis.binding.BindingException' exception.Invalid bound statement (not found)……的相关文章

org.apache.ibatis.binding.BindingException: Parameter &#39;start&#39; not found. Available parameters are [1, 0, param1, param2]

DEBUG 2018-05-30 08:43:26,091 org.springframework.jdbc.datasource.DataSourceTransactionManager: Rolling back JDBC transaction on Connection [[email protected]]DEBUG 2018-05-30 08:43:26,091 org.mybatis.spring.SqlSessionUtils$SqlSessionSynchronization:

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): da.huying.usermanage.mapper.UserMapper.queryUserById    at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:196)    at org.apache.ibatis.bindi

IDEA异常解决: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

有时候解决问题不仅仅是解决问题.-----jstarseven 最近因为开发需要,需要搭建一个ssm开发框架,采用了开发工具IDEA. 整合完了SSM开发框架之后,发布的时候出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found... 一开始以为是自己配置文件写的有问题找了半天也没有问题,之后才发现是自己对IDEA工具使用的不够熟悉. 先说该异常常见解决方案: 一般是xml映射文件有错误.但

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.baway.dao.UserMapper.register

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.baway.dao.UserMapper.register    at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:189)    at org.apache.ibatis.binding.MapperMethod.<

报错org.apache.ibatis.binding.BindingException: Type interface com.atguigu.mybatis.bean.dao.EmployeeMapper is not known to the MapperRegistry.

我报这个错误的原因是因为mybatis-config.xml配置文件中 <!-- 批量注册: --> <package name="com.atguigu.mybatis.dao"/> 没有写对,根据路径改正就可以了.比如说应该写成 <package name="com.atguigu.mybatis.dao"/> 结果我写成了 <package name="com.atguigu.mybatis.bean.dao

转:IDEA异常解决: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

原文地址:https://www.cnblogs.com/jstarseven/p/5803697.html 有时候解决问题不仅仅是解决问题.-----jstarseven 最近采用了开发工具IDEA开发SSM开发框架完成后,发布的时候出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found... 一开始以为是自己配置文件写的有问题找了半天也没有问题,之后才发现是自己对IDEA工具使用的不够熟

【Mybatis异常】 org.apache.ibatis.binding.BindingException: Parameter &#39;storeId&#39; not found. Available parameters are [form, param1]

一.异常信息 2019-05-31 16:06:25.272 [http-nio-10650-exec-3] WARN o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver.logException(AbstractHandlerExceptionResolver.java:192) - Resolved exception caused by Handler execution: org.mybatis.spring.MyBatisSystemExce

IDEA+Maven+Mybatis 巨坑:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.rao.mapper.UserMapper.findAll

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.rao.mapper.UserMapper.findAll at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:227) at org.apache.ibatis.binding.MapperMethod.<init&

通过maven test 报org.apache.ibatis.binding.BindingException: Invalid bound statement

背景 直接使用eclipse工具去执行,没有问题,通过testng.xml去执行,没有问题,但通过mvn clean test执行,就报错,提示org.apache.ibatis.binding.BindingException: Invalid bound statement 解决方法 首先先肯定的是:mybatis的配置是没有问题,因为eclipse可以正常执行: 在eclipse中把mapper的xml文件放到src代码目录下是可以一起打包进classes的,而maven去编译的时候不会,