关于IDEA工具在springboot整合mybatis中出现的Invalid bound statement (not found)问题
来源:互联网 发布:2017广电总局 网络盒子 编辑:程序博客网 时间:2024/05/16 17:54
第一次写博客。有点小激动。
笔者因为工作需要,所以需要学习springboot和springcloud,而开发工具则是公司要求使用的IDEA2017,笔者之前的开发工具是Myeclipse.
换了工具有诸多的不适应,还在慢慢的熟悉
在学习过程中难免有些磕磕碰碰,几天下来碰到了N个问题
一直有个想法,想把学习与工作过程中的错误与灵感都记录下来,却一直苦于没有什么时间而没去动笔
今天在学习springboot与mybatis整合中,使用了注解+xml的开发.
pom.xml引的几个重要依赖
<dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId></dependency><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>1.3.0</version></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-test</artifactId><version>4.3.10.RELEASE</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-test</artifactId><version>1.5.6.RELEASE</version></dependency>
这是笔者的接口mapper
@Mapperpublic interface UserMapper { List<User> likeName(String name); User getById(Integer id);}
这是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"><mapper namespace="com.example.demo.UserMapper"> <resultMap id="userMap" type="com.example.demo.User"> <id property="id" column="id" /> <result property="name" column="name" /> <result property="age" column="age" /> </resultMap> <select id="getById" resultMap="userMap" parameterType="int"> SELECT * FROM USER WHERE ID = #{id} </select></mapper>
测试文件
@RunWith(SpringJUnit4ClassRunner.class)@SpringBootTest(classes = DemoApplication.class)public class MybatisTest { @Autowired private UserMapper userMapper; @Test public void getById() throws Exception { User user = userMapper.getById(1); System.out.println(user); }}
在一切准备就绪之后,测试test,却出现了org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
这个问题,通常情况下,这是xml文件与接口mapper不对应导致的. 但我仔细检查了一遍,没有发现错误.
在查阅过相关资料后发现,IDEA对xml文件处理的方式不同. mapper.xml文件需要放置在resource这个文件夹下.
而eclipse只要mapper接口文件与mapper.xml放置在同一平级目录就行
阅读全文
0 0
- 关于IDEA工具在springboot整合mybatis中出现的Invalid bound statement (not found)问题
- Mybatis - 在idea中错误:Invalid bound statement (not found)
- Mybatis在idea中错误:Invalid bound statement (not found)
- Mybatis在idea中错误:Invalid bound statement (not found)
- Mybatis在idea中错误:Invalid bound statement (not found)
- Invalid bound statement (not found)-Mybatis在idea中错误
- IDEA的Maven项目整合Spring和Mybatis框架出现ibatis.binding.BindingException: Invalid bound statement (not found)
- 【mybatis】【idea】【maven】Invalid bound statement (not found)的解决
- mybatis中出现Invalid bound statement (not found)
- 关于mybatis Invalid bound statement (not found) 问题
- mybatis一个怪异的问题: Invalid bound statement (not found)
- mybatis一个怪异的问题: Invalid bound statement (not found)
- mybatis一个怪异的问题: Invalid bound statement (not found)
- mybatis一个怪异的问题: Invalid bound statement not found":
- mybatis一个怪异的问题: Invalid bound statement (not found)
- mybatis一个怪异的问题: Invalid bound statement not found"
- springboot 集成mybatis Invalid bound statement (not found)异常
- Springboot mybatis集成 Invalid bound statement (not found)....
- JDBC之preparedStatement
- Error LNK2001 无法解析的外部符号 的几种情况及解决办法
- hdu6119 尺取 双指针
- PHP关于(类对象)回调方法的使用
- phpl判断mysq数据库中的某个数据表是否存在的方法总结
- 关于IDEA工具在springboot整合mybatis中出现的Invalid bound statement (not found)问题
- HDU1160DP最长上升子序列微整形
- 尔石山
- java-三角形矩形输入长宽求面积周长等
- 火狐浏览器导出EXCEL 表格,文件名乱码问题
- OJ.2456: 评委打分
- spring boot +logback实现error级别日志报警
- Apache的ProxyPass简单使用
- IP地址的划分及其范围