`

153. Spring Boot MyBatis升级篇- pagehelper替换为pagehelper-spring-boot-starter

阅读更多

 

【视频&交流平台】

à SpringBoot视频

http://study.163.com/course/introduction.htm?courseId=1004329008&utm_campaign=commission&utm_source=400000000155061&utm_medium=share

à SpringCloud视频

http://study.163.com/course/introduction.htm?courseId=1004638001&utm_campaign=commission&utm_source=400000000155061&utm_medium=share

à Spring Boot源码

https://gitee.com/happyangellxq520/spring-boot

à Spring Boot交流平台

http://412887952-qq-com.iteye.com/blog/2321532

 

对于Spring Boot中使用Pagehelper,现在开放了一个pagehelper-spring-boot-starter,能够更简单的进行集成,这个start1.1.3版本)使用的是5.0.4pagehelper。那么如何使用呢?

 

第一步:pom.xml依赖替换

       pagehelper替换为:pagehelper-spring-boot-starter,具体操作:

 

删除掉如下的依赖(如果是直接使用的,不是替换的话,直接引入如下依赖):

<dependency>
	    <groupId>com.github.pagehelper</groupId>
	    <artifactId>pagehelper</artifactId>
		<version>4.1.0</version>
</dependency>

 

添加如下的依赖:

    <dependency>
        <groupId>com.github.pagehelper</groupId>
        <artifactId>pagehelper-spring-boot-starter</artifactId>
        <version>1.1.3</version>
 
    </dependency>

 

 

第二步:删除配置类MyBatisConfiguration

 

       之前在这个类里面我们注入了PageHelper,这里可以直接把这个配置类删除掉了,用不上了(如果是直接使用的话,那么这个这个步骤直接跳过,往下操作即可)。

第三步:在application.properties添加配置信息

pagehelper.helperDialect=mysql
pagehelper.reasonable=true
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql

 

       其实就是把我们的配置信息从Java类移到了配置文件。

 

 第四步:测试

       访问一下之前编写的代码,看是否可以即可:

http://127.0.0.1:8080/selectAll?pageNum=2

 

视频&交流平台

à SpringBoot网易云课堂视频

http://study.163.com/course/introduction.htm?courseId=1004329008

à Spring Boot交流平台

http://412887952-qq-com.iteye.com/blog/2321532

 

 

 

 

 

 

 

分享到:
评论
2 楼 林祥纤 2017-09-25  
lixuejian 写道
   


1 楼 lixuejian 2017-09-25  
   

相关推荐

    mybatis-spring-boot-starter-2.1.3.jar

    mybatis-spring-boot-starter-2.1.3.jarmybatis-spring-boot-starter-2.1.3.jarmybatis-spring-boot-starter-2.1.3.jar

    mybatis-spring-boot-starter-2.1.4.jar

    mybatis-spring-boot-starter-2.1.4.jarmybatis-spring-boot-starter-2.1.4.jar

    mybatis-spring-boot-starter-2.0.0.jar

    mybatis mybatis-spring-boot-starter-2.0.0.jar下载

    mybatis-plus-boot-starter-3.1.1.jar

    java运行依赖jar包

    spring-boot-starter-mybatis-spring-boot-1.0.2.zip

    "spring-boot-starter-mybatis-spring-boot-1.0.2"这个版本即为该起步依赖的一个特定版本,适用于Windows环境。 2. 集成步骤 (1) 添加依赖:在项目的pom.xml或build.gradle文件中,引入Spring Boot Starter ...

    mybatis-spring-boot-starter-3.0.1.jar

    MyBatis Spring Boot Starter.jar 各个版本,免费下载。 MyBatis Spring Boot Starter.jar 起步依赖和自动配置。

    mybatis-spring-boot-starter-2.0.1.jar

    mybatis-spring-boot-starter-2.0.1.jarmybatis-spring-boot-starter-2.0.1.jarmybatis-spring-boot-starter-2.0.1.jar

    mybatis-plus-boot-starter-3.5.3.1.jar

    mybatis-plus-boot-starter.jar 各个版本下载, SpringBoot 集成 MybatisPlus jar 包下载, Mybatis-Plus(简称MP)是一个基于MyBatis的增强工具库,它简化了与数据库的交互操作并提供了一系列增强功能,使开发者...

    mybatis-spring-boot-starter初探 代码.zip

    关于mybatis的spring boot可执行代码,对应的解说博客地址在:https://blog.csdn.net/heidashou/article/details/105812796,含有全过程截图和解说。

    spring-boot-starter-mybatis-spring-boot-1.3.3.tar.gz

    在`pom.xml`文件中,我们需要引入`spring-boot-starter-data-jpa`和`spring-boot-starter-web`,同时,添加`spring-boot-starter-mybatis`的依赖。例如: ```xml &lt;!-- ...其他依赖... --&gt; &lt;groupId&gt;org....

    mybatis-plus-boot-starter-3.4.3.3.jar

    mybatis-plus-boot-starter.jar 各个版本下载, SpringBoot 集成 MybatisPlus jar 包下载, Mybatis-Plus(简称MP)是一个基于MyBatis的增强工具库,它简化了与数据库的交互操作并提供了一系列增强功能,使开发者...

    spring-boot-starter-mybatis-spring-boot-2.1.2.zip

    `spring-boot-starter-mybatis`是Spring Boot为MyBatis提供的一站式解决方案,它包含MyBatis核心库、MyBatis-Spring以及相关的依赖,使得开发者无需手动管理这些依赖,只需简单配置即可实现MyBatis的集成。...

    spring-boot-starter-mybatis-spring-boot-2.3.0.tar.gz

    本文将以`spring-boot-starter-mybatis-spring-boot-2.3.0`为例,深入解析Spring Boot如何集成MyBatis,并探讨其在Linux环境下的部署与使用。 一、Spring Boot集成MyBatis 1. 添加依赖 首先,在Spring Boot项目中...

    spring-boot-starter-mybatis-spring-boot-2.2.1.zip

    在Windows环境下,你可以免费下载`spring-boot-starter-mybatis-spring-boot.zip`不同版本的压缩包,以适应不同的项目需求。务必确保选择与项目中其他依赖相匹配的版本,以避免潜在的兼容性问题。 总结,Spring ...

    spring-boot-starter-mybatis-spring-boot-1.3.4.zip

    `spring-boot-starter-mybatis`是Spring Boot为MyBatis提供的一个starter,它包含了MyBatis、MyBatis-Spring、以及相关的依赖,使得开发者可以方便地在Spring Boot项目中使用MyBatis。在`pom.xml`或`build.gradle`...

    spring-boot-starter-mybatis-spring-boot-1.1.1.zip

    首先,`spring-boot-starter-mybatis`是Spring Boot为MyBatis提供的一个起步依赖,它简化了MyBatis在Spring Boot中的配置和使用。通过引入这个依赖,我们可以快速地在Spring Boot项目中构建起MyBatis的数据访问层。 ...

    spring-boot-starter-mybatis-spring-boot-1.3.1.zip

    首先,我们关注的是`spring-boot-starter-mybatis-spring-boot-1.3.1.zip`这个压缩包,它是Spring Boot 1.3.1版本中用于集成MyBatis的起步依赖。这个起步依赖包含了运行Spring Boot项目时所需要的MyBatis核心组件,...

    spring-boot-starter-mybatis-spring-boot-1.3.3.zip

    Spring Boot通过`spring-boot-starter`系列模块简化了依赖管理,`spring-boot-starter-mybatis`便是其中一员,它为Spring Boot项目提供了自动配置MyBatis的功能。该模块包含了MyBatis的核心库、Spring的MyBatis支持...

    spring-boot-starter-mybatis-spring-boot-2.3.1.tar.gz

    《Spring Boot集成MyBatis详解:以spring-boot-starter-mybatis-2.3.1为例》 在现代Java开发中,Spring Boot以其简洁、高效的特点成为首选框架,而MyBatis作为轻量级的持久层框架,也因其灵活的数据访问能力受到...

    spring-boot-starter-mybatis-spring-boot-1.2.1.tar.gz

    本文将围绕"spring-boot-starter-mybatis-spring-boot-1.2.1.tar.gz"这个压缩包,详细介绍Spring Boot 1.2.1版本集成MyBatis的相关知识。 1. **Spring Boot Starter MyBatis简介** Spring Boot Starter MyBatis是...

Global site tag (gtag.js) - Google Analytics