上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 24 下一页
摘要: lombok偷懒专用,最好少用,降低代码可读性 1.idea中安装Lombok 2.在项目中导入Lombok的jar包(到maven仓库里找) <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifact 阅读全文
posted @ 2021-12-23 10:54 卡卡发 阅读(23) 评论(0) 推荐(0) 编辑
摘要: 使用注解开发 UserMapper: public interface UserMapper{ @Select("select * from mybatistest.user") List<User> getUserList(); } MyBatis-config: <!--绑定接口--> <map 阅读全文
posted @ 2021-12-23 09:59 卡卡发 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 为什么要分页? 减少数据的处理量 1.使用limit分页 select * from user where limit startindex,pagesize; 2.Mybatis里用limit List<User> getUserByLimit(Map<String,Integer> map); 阅读全文
posted @ 2021-12-18 15:36 卡卡发 阅读(29) 评论(0) 推荐(0) 编辑
摘要: log4j 阅读全文
posted @ 2021-12-17 19:52 卡卡发 阅读(21) 评论(0) 推荐(0) 编辑
摘要: 解决属性名和字段名不一致的问题 解决办法: 1.起别名 2.resultMap 结果集映射 一个例子: <!-- resultMap最终还是要将结果映射到pojo上,type就是指定映射到哪一个pojo --> <!-- id:设置ResultMap的id --> <resultMap type=" 阅读全文
posted @ 2021-12-17 17:01 卡卡发 阅读(25) 评论(0) 推荐(0) 编辑
摘要: ![](https://img2020.cnblogs.com/blog/2181692/202112/2181692-20211217160620030-362666689.png) ![](https://img2020.cnblogs.com/blog/2181692/202112/2181692-20211217160703642-1089726659.png) ![](https://i 阅读全文
posted @ 2021-12-17 16:08 卡卡发 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 注册绑定mapper文件 1.方式一:推荐使用 <mappers> <mapper resource="com/kakafa/dao/UserMapper.xml"/> </mappers> 2.方式二:用class文件绑定注册 <mappers> <mapper class="com.kakafa 阅读全文
posted @ 2021-12-17 15:55 卡卡发 阅读(64) 评论(0) 推荐(0) 编辑
摘要: 配置要按照顺序来: 1.给实体类起别名: 2.也可以给实体类起别名:MyBatis会在指定的包名下搜索需要的JavaBean,默认的别名即为这个类的类名,首字母小写! 在实体类比较多的时候建议使用第二种,但是第一种可以自定义别名;第二种不行,其默认别名就是首字母小写的类名。 如果第二种非要自定义名字 阅读全文
posted @ 2021-12-17 15:32 卡卡发 阅读(63) 评论(0) 推荐(0) 编辑
摘要: 1.环境配置environments myBatis可以配置成适应多种环境,但是每个sqlSessionFactory实例只能选择一种环境 myBatis默认事务管理器时jdbc,连接池:pooled 2.属性properties 外部配置文件 db.properties: driver=com.m 阅读全文
posted @ 2021-12-17 14:40 卡卡发 阅读(41) 评论(0) 推荐(0) 编辑
摘要: 假设实体类或者数据库中的表,参数字段太多,我们应当使用Map,这样只需要修改或者插入需要的几个参数即可。 1.map 以插入为例子如下: 原来: 使用map: 测试: @Test public void addUser2(){ SqlSession sqlSession = MybatisUtils 阅读全文
posted @ 2021-12-17 10:57 卡卡发 阅读(78) 评论(0) 推荐(0) 编辑
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 24 下一页