分页插件PageHelper+spring单元测试
来源:互联网 发布:算法工程师面试题 编辑:程序博客网 时间:2024/06/03 10:59
spring单元测试---注解法
1、junit单元测试包
<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency>
2、spring测试包
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>4.1.3.RELEASE</version> </dependency>3、测试类
@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration({"classpath:spring/applicationContext-*.xml"})public class TestPageHelper {...}
spring单元测试---手动装载
1、junit测试包
<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency>2、测试类
@Test public void testPageHelper1(){ //获得mapper代理对象 ApplicationContext context = new ClassPathXmlApplicationContext("classpath:spring/applicationContext-*.xml"); TbItemMapper itemMapper = context.getBean(TbItemMapper.class); ...}
PageHelper分页
1、分页jar包
<dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>4.0.2</version> </dependency>
2、mybatis配置(SqlMapConfig.xml)
<!--配置分页插件--> <plugins> <plugin interceptor="com.github.pagehelper.PageHelper"> <!--指定数据库方言--> <property name="dialect" value="mysql"/> </plugin> </plugins>
3、java代码
@Autowired private TbItemMapper tbItemMapper; //注解加载配置问价 @Test public void testPageHelper(){ //设置分页 PageHelper.startPage(1,30); //执行查询 TbItemExample example = new TbItemExample(); List<TbItem> list = tbItemMapper.selectByExample(example); //取分页结果 PageInfo<TbItem> pageInfo = new PageInfo<>(list); long total = pageInfo.getTotal(); System.out.println("total:"+total); int pages = pageInfo.getPages(); System.out.println("pages:"+pages); int pageSize = pageInfo.getPageSize(); System.out.println("pageSize:"+pageSize); }OK!
阅读全文
0 0
- 分页插件PageHelper+spring单元测试
- spring+mybatis利用pageHelper分页插件分页
- 关于Spring+mybatis+PageHelper分页插件PageHelper的使用策略
- Spring+mybatis+PageHelper分页插件PageHelper的使用
- Spring + Mybatis 使用 PageHelper 插件分页
- Maven+Spring + Mybatis 使用 PageHelper 插件分页
- Spring + Mybatis 使用 PageHelper 插件分页
- Spring + Mybatis 使用 PageHelper 插件分页
- Spring + Mybatis 使用 PageHelper 插件分页
- Spring中集成Mybatis分页插件PageHelper
- MyBatis分页插件PageHelper
- mybatis分页插件pagehelper
- Mybaties PageHelper分页插件
- Mybatis分页插件-pagehelper
- Mybatis分页插件 - PageHelper
- Mybatis分页插件PageHelper
- PageHelper分页插件使用
- 分页插件PageHelper
- 数据结构--数组类之StaticArray类
- Nginx工作原理和优化、漏洞。
- 51串口通信篇
- matlab生成A2L的变量地址更新的几种方法
- java集合类框架
- 分页插件PageHelper+spring单元测试
- 基于HTTP模拟实现静态服务器-多任务多进程
- Java Struts2 框架入门详解(三)简单的实例
- 高晓松 鱼羊野史(全六卷)(ED2000.COM).epub 免费下载
- Lighttpd源码分析之状态机与插件
- JAVA 向数据库中插入数据并获取主键的方法(逐渐补充)
- python重命名
- Python微型web开发框架flask介绍及一个小例子
- Codeforces Round #451 (Div. 2)