ibatis

mybatis注解开发

自作多情 提交于 2020-02-16 23:38:19
在mybatis中针对CRUD一共有四个注解: @Select(),@Delete(),@Insert(),@Update() 示例: 在mybatis-config.xml中 < mappers > < ! -- < package name = "net.togogo.dao" > < / package > -- > < mapper class = "net.togogo.dao.IUserDao" > < / mapper > < / mappers > /** * 查询所有操作 * @return */ @Select ( "select * from user" ) List < User > findAll ( ) ; /** * 根据Id查询 */ @Select ( "select * from user where id = #{id}" ) User findById ( Integer id ) ; 当User类中的属性名和数据库的字段名不一致时可以这样: 一对一 mybatis-config.xml中: < mapper class = "net.togogo.dao.IAccountDao" > < / mapper > IAccountDao.java中 package net . togogo . dao ; import net . togogo

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

筅森魡賤 提交于 2020-02-16 09:52:58
疫情期间,居家办公,开始写后台代码,用IDEA大环境,新建maven工程始终失败,原因未知,折腾一上午。为了赶时间, 只能不在纠结环境,拷贝老项目,将pom.xml中的部分内容修改后,maven clean 运行跑起来,然后开始兴致勃勃地写代码, 写完第一个接口之后,开始在test目录写测试代码操作数据库,没想到接下的错误,折腾了我一个下午: [/frontend-integration/frontendIntegration/system/addFrontendSystem] is: -1 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.hnac.hzinfo.frontend.sysintegration.dao.FrontendIntegrationMapper.selectByExample at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:225) at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:48) at org.apache.ibatis.binding

MyBatis的注解配置

﹥>﹥吖頭↗ 提交于 2020-02-09 01:44:08
之前我们MaBatis的增删改查,关联映射、动态SQL语句等知识,其所有配置都是通过XML完成的,编写大量的XML配置比较繁琐。注解还是更简单一点的,从章节分配上就能看出来,前面的写了三章,注解的就一章搞定 基于注解的单表增删改查 1.既然时要基于注解,那就要把之前基于xml的删掉然后再mapper下新建一个接口 package com . mybatis . mapper ; import java . util . List ; import org . apache . ibatis . annotations . Delete ; import org . apache . ibatis . annotations . Insert ; import org . apache . ibatis . annotations . Select ; import org . apache . ibatis . annotations . Update ; import com . mybatis . pojo . UserInfo ; public interface UserInfoMapper { //根据用户编号查询用户 @Select ( "select * from user_info where id=#{id}" ) public UserInfo

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

匆匆过客 提交于 2020-02-08 13:01:22
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题,即在 mybatis中dao接口与mapper配置文件在做映射绑定 的时候出现问题,简单说,就是接口与xml要么是找不到,要么是找到了却匹配不到。 截图为网络中搜索到的常见原因: 照着修改之后,问题依旧存在。最终花费了好大的力气才找到自己代码问题的根源。 dao接口与xml的文件名不一致。 接口名与接口文件名都是DepartmentDao, 而配置文件名为DeparmentDao.xml,费了很大的劲才看到两者名字差一个t字母。修改后就一切正常了。 这是一个很容易忽视的点,记住:接口名与Mybatis的映射文件名一定要一模一样。 来源: https://www.cnblogs.com/xianyao/p/12275994.html

project2.ssm实现的注册功能.3.Controller

瘦欲@ 提交于 2020-02-07 21:57:27
1.用到的注解的含义 1.1@RequestMapping @RequestMapping("")用于匹配Http请求中的请求路径url 可以通过value=“url”,produces = "application/json;charset=UTF-8"来改变返回值编码类型,但是之前在annotation中已经统一配置过了,不需要再写。 1.2@ResponseBody @ResponseBody表示返回值跳过视图解析器,写入response的body区域 1.3@RequestBody @RequestBody表示请求体的参数要和其注解的参数匹配 2.我对controller中解析参数和其它过程的看法 鲁二蛋ssm开发原则:controller中故每个函数尽可能短,更加一目了然,尽可能调用辅助类 package com.project2.controller; import java.io.IOException; import java.io.InputStream; import org.apache.ibatis.io.Resources; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.apache

org.apache.ibatis.binding.BindingException: Parameter 'idList' not found解决办法

两盒软妹~` 提交于 2020-02-07 18:04:51
https://blog.csdn.net/qq_28379809/article/details/83342196 问题描述 使用Mybatis查询数据库报错: org.apache.ibatis.binding.BindingException: Parameter 'idList' not found 1 接口是这样的: public List<User> findByIdList(List<Integer> idList); 1 XML是这样的: <select id="findByIdList" resultType="com.example.bean.User"> SELECT id, name, password, address, enable FROM user <where> <if test="idList != null and idList.size() > 0"> id IN <foreach collection="idList" item="ietm" index="index" open="(" separator="," close=")"> #{item} </foreach> </if> </where> </select> 1 2 3 4 5 6 7 8 9 10 11 12 运行报错:org.apache.ibatis.binding

【Mybatis】报错:org.apache.ibatis.type.TypeException: The alias 'Collection' is already mapp

假如想象 提交于 2020-02-06 20:19:51
jar包有同类名,冲突了。加个别名就好了 import org.apache.ibatis.type.Alias; @Alias("tb_collection") public class Collection { } 来源: CSDN 作者: winrh 链接: https://blog.csdn.net/qq_32117641/article/details/104196664

ibatis in 1000 仅供参考

送分小仙女□ 提交于 2020-02-06 02:24:39
SQL的動態where 拼寫實現 /** * or 拼 in(num个) * 列名 * list * in中多少个元素 */ public String createSql(String col, List<String> partners, int num) { StringBuffer sb = new StringBuffer(); // COL in (1,2,3,4,5,6) // or // COL in (7,8,9,10,11,12) // -> // COL in ( // 1,2,3,4,5,6) // or COL in ( // 7,8,9,10,11,12) sb.append(col + " in ("); int size = partners.size(); for (int i=1;i<(size+1);i++) { int shang = i/num; int yushu = i%num; if(yushu == 0){ sb.append("'" + partners.get(i-1) + "')"); if((i!=size)&&(shang != 0)){ sb.append(" or "); sb.append(col + " in ("); } }else{ if(i==size){ sb.append("'" + partners

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

送分小仙女□ 提交于 2020-02-05 16:33:10
异常信息:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 原因分析: 出现此异常时因为接口和映射的mapper文件不再同一目录下所致。 但是代码中看到是在同一个目录下的 后来查看了编译后的文件,发现真的没有 这是为什么呢??? 后来经过分析,得出结论。这是因为 maven工程在默认情况下src/main/java目录下的mapper文件是不发布到target目录下的。 解决办法: 解决办法很简单:在pom.xml文件中添加资源映射 还有一种方法就是 把mapper文件放到resource资源路径下,我的项目中都放到了src/main/java下了,所以在pom.xml文件中添加了以上的配置。 来源: https://www.cnblogs.com/wlv1314/p/12264169.html

常用资源发布

﹥>﹥吖頭↗ 提交于 2020-02-05 08:41:27
Address Tag http://www.51goodjob.com.cn/TechManualView.asp?id=166 51goodjob 找工作 http://www.arpun.com/soft/2370.html OllyDBG 2.0 汉化版 OD 调试工具 破解工具 https://myc-n:8443/svn/test/HashPassword HashPassword asp.net产生随机密码 SVN local http://www.aspheute.com/english/20040105.asp HashPassword asp.net产生随机密码 http://www.asp.net/security/tutorials/user-based-authorization-cs User-Based Authorization 用户角色 userRole https://myc-n:8443/svn/test/ASPNET_Security_Tutorial_07_CS User-Based Authorization 用户角色 userRole svn local http://www.debugman.com/ # debugman 破解论坛 http://bbs.jkcing.com/ 甲壳虫论坛 软件破解 http://vip