PageHelper-Spring-Bootを参照してください。これは非常に便利です。 PageHelperの詳細については、https://github.com/pagehelper/mybatis-pagehelperをクリックできます。
Spring BootがMyBatisを統合するとき、最初にそれをページングする必要があります。
<Dependency> groupId> com.github.pagehelper </groupid> <artifactid> pagehelper </artifactid> <version> 5.1.2 </version> </dependency> <dependency> <groupid> com.github.pagehelper </groupid> <artifactid> pagehelper-spring-boot-autoconfiguure <バージョン> 1.2.3 </version> </dependency> <依存関係> <groupid> com.github.pagehelper </groupid> <artifactid> pagehelper-spring-boot-starter </artifactid> <バージョン> 1.2.3 </version> </dependency>
方法1:Application.yml(春に読む必要があるYML)に追加
PageHelper:helperdialect:mysql reasure:true supportmethodsarguments:true params:count = countsql
その後、再起動します。
構成ファイルは最終的にJavaによって読み取られ、Spring Beanに注入されます。したがって、2番目の方法は、Beanクラスを構成することです。ホットロードは簡単に変更できます。もちろん、この方法はより簡単です。
方法2:注釈カバーパッケージの下に新しいPageHelePerconfigを作成する
com.github.pagehelper.pagehelper; import java.util.properties; Import org.springframework.context.annotation.bean; import org.springframework.context.annotation.configuration;/** * @author zhuxiaomeng * @date 2018/1/1. * @email [email protected] */ @configurationpublic class pagehelperconfig {@bean publichelper getpagehelper(){pagehelper pagehelper = new pagehelper();プロパティプロパティ= new Properties(); properties.setProperty( "helperdialect"、 "mysql"); properties.setProperty( "Reasureable"、 "True"); properties.setProperty( "supportmethodsarguments"、 "true"); properties.setProperty( "params"、 "count = countsql"); pagehelper.setProperties(プロパティ); PageHelperを返します。 }}
PageHelperの基本的な知識は次のとおりです。
Import com.github.pagehelper.page; Import com.github.pagehelper.pagehelper;
ページ<t> tpage = pagehelper.startpage(page、lime);
次のクエリステートメントは、ページングに使用されます。リスト<t>でそれを受け取る必要があります
質問がある場合は、オープンソースプロジェクトLenosをダウンロードして足場をすばやく開発できます。SpringBootバージョンは学習に精通しています。
住所:https://gitee.com/bweird/lenosp
上記はこの記事のすべての内容です。みんなの学習に役立つことを願っています。誰もがwulin.comをもっとサポートすることを願っています。