




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
【移動應(yīng)用開發(fā)技術(shù)】Springboot2中如何集成pagehelper
這篇文章主要介紹“Springboot2中如何集成pagehelper”的相關(guān)知識,在下通過實(shí)際案例向大家展示操作過程,操作方法簡單快捷,實(shí)用性強(qiáng),希望這篇“Springboot2中如何集成pagehelper”文章能幫助大家解決問題。1、pom.xml<?xml
version="1.0"
encoding="UTF-8"?>
<project
xmlns="/POM/4.0.0"
xmlns:xsi="/2001/XMLSchema-instance"
xsi:schemaLocation="/POM/4.0.0
/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>
<relativePath/>
<!--
lookup
parent
from
repository
-->
</parent>
<groupId>qinfeng.zheng</groupId>
<artifactId>learnquery</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>learnquery</name>
<description>Demo
project
for
Spring
Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.12</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>2.application.peroperties#pagehelperpagehelper.helper-dialect=mysqlpagehelper.params=count=countSqlpagehelper.reasonable=truepagehelper.support-methods-arguments=true#mysqlspring.datasource.driver-class-name=com.mysql.jdbc.Driverspring.datasource.url=jdbc:mysql://120.79.xx.xx:3306/test?useUnicode=yes&characterEncoding=UTF-8&useSSL=falsespring.datasource.username=rootspring.datasource.password=1212212#pagehelperpagehelper.helper-dialect=mysqlpagehelper.params=count=countSqlpagehelper.reasonable=truepagehelper.support-methods-arguments=true#mysqlspring.datasource.driver-class-name=com.mysql.jdbc.Driverspring.datasource.url=jdbc:mysql://120.79.xx.xx:3306/test?useUnicode=yes&characterEncoding=UTF-8&useSSL=falsespring.datasource.username=rootspring.datasource.password=12122123.實(shí)體類public
class
Country
implements
Serializable
{
private
static
final
long
serialVersionUID
=
6569081236403751407L;
private
int
id;
private
String
countryname;
private
String
countrycode;
public
int
getId()
{
return
id;
}
public
void
setId(int
id)
{
this.id
=
id;
}
public
String
getCountryname()
{
return
countryname;
}
public
void
setCountryname(String
countryname)
{
this.countryname
=
countryname;
}
public
String
getCountrycode()
{
return
countrycode;
}
public
void
setCountrycode(String
countrycode)
{
this.countrycode
=
countrycode;
}
}4,mapper接口類@Mapper
public
interface
CountryMapper
{
@Select("select
*
from
country")
List<Country>
findAll();
}5.cotroller類@RestController
public
class
CountryController
{
@Autowired
private
CountryMapper
countryMapper;
@GetMapping("/findAll")
public
List<Country>
findAll(@RequestParam(defaultValue
=
"1")
Integer
pageNum,
@RequestParam(defaultValue
=
"20")
Integer
pageSize)
{
PageHelper.startPage(pageNum,
pageSize);
List<Country>
countries
=
countryMapper.findAll();
Page
page
=
(Page)
countries;
System.out.println("每頁展示條數(shù):"
+
page.getPageSize());
System.out.println("總條數(shù):"
+
page.getTotal());
System.out.println("當(dāng)前頁:"
+
page.getPageNum());
System.out.println("總頁數(shù):"
+
page.getPages());
return
countries;
}
}7.測試數(shù)據(jù)直接抄官方數(shù)據(jù)drop
table
country
if
exists;
create
table
country
(
id
int
primary
key
auto_increment,
countryname
varchar(32),
countrycode
varchar(2)
);
insert
into
country
(id,
countryname,
countrycode)
values(1,'Angola','AO');
insert
into
country
(id,
countryname,
countrycode)
values(2,'Afghanistan','AF');
insert
into
country
(id,
countryname,
countrycode)
values(3,'Albania','AL');
insert
into
country
(id,
countryname,
countrycode)
values(4,'Algeria','DZ');
insert
into
country
(id,
countryname,
countrycode)
values(5,'Andorra','AD');
insert
into
country
(id,
countryname,
countrycode)
values(6,'Anguilla','AI');
insert
into
country
(id,
countryname,
countrycode)
values(7,'Antigua
and
Barbuda','AG');
insert
into
country
(id,
countryname,
countrycode)
values(8,'Argentina','AR');
insert
into
country
(id,
countryname,
countrycode)
values(9,'Armenia','AM');
insert
into
country
(id,
countryname,
countrycode)
values(10,'Australia','AU');
insert
into
country
(id,
countryname,
countrycode)
values(11,'Austria','AT');
insert
into
country
(id,
countryname,
countrycode)
values(12,'Azerbaijan','AZ');
insert
into
country
(id,
countryname,
countrycode)
values(13,'Bahamas','BS');
insert
into
country
(id,
countryname,
countrycode)
values(14,'Bahrain','BH');
insert
into
country
(id,
countryname,
countrycode)
values(15,'Bangladesh','BD');
insert
into
country
(id,
countryname,
countrycode)
values(16,'Barbados','BB');
insert
into
country
(id,
countryname,
countrycode)
values(17,'Belarus','BY');
insert
into
country
(id,
countryname,
countrycode)
values(18,'Belgium','BE');
insert
into
country
(id,
countryname,
countrycode)
values(19,'Belize','BZ');
insert
into
country
(id,
countryname,
countrycode)
values(20,'Benin','BJ');
insert
into
country
(id,
countryname,
countrycode)
values(21,'Bermuda
Is.','BM');
insert
into
country
(id,
countryname,
countrycode)
values(22,'Bolivia','BO');
insert
into
country
(id,
countryname,
countrycode)
values(23,'Botswana','BW');
insert
into
country
(id,
countryname,
countrycode)
values(24,'Brazil','BR');
insert
into
country
(id,
countryname,
countrycode)
values(25,'Brunei','BN');
insert
into
country
(id,
countryname,
countrycode)
values(26,'Bulgaria','BG');
insert
into
country
(id,
countryname,
countrycode)
values(27,'Burkina-faso','BF');
insert
into
country
(id,
countryname,
countrycode)
values(28,'Burma','MM');
insert
into
country
(id,
countryname,
countrycode)
values(29,'Burundi','BI');
insert
into
country
(id,
countryname,
countrycode)
values(30,'Cameroon','CM');
insert
into
country
(id,
countryname,
countrycode)
values(31,'Canada','CA');
insert
into
country
(id,
countryname,
countrycode)
values(32,'Central
African
Republic','CF');
insert
into
country
(id,
countryname,
countrycode)
values(33,'Chad','TD');
insert
into
country
(id,
countryname,
countrycode)
values(34,'Chile','CL');
insert
into
country
(id,
countryname,
countrycode)
values(35,'China','CN');
insert
into
country
(id,
countryname,
countrycode)
values(36,'Colombia','CO');
insert
into
country
(id,
countryname,
countrycode)
values(37,'Congo','CG');
insert
into
country
(id,
countryname,
countrycode)
values(38,'Cook
Is.','CK');
insert
into
country
(id,
countryname,
countrycode)
values(39,'Costa
Rica','CR');
insert
into
country
(id,
countryname,
countrycode)
values(40,'Cuba','CU');
insert
into
country
(id,
countryname,
countrycode)
values(41,'Cyprus','CY');
insert
into
country
(id,
countryname,
countrycode)
values(42,'Czech
Republic','CZ');
insert
into
country
(id,
countryname,
countrycode)
values(43,'Denmark','DK');
insert
into
country
(id,
countryname,
countrycode)
values(44,'Djibouti','DJ');
insert
into
country
(id,
countryname,
countrycode)
values(45,'Dominica
Rep.','DO');
insert
into
country
(id,
countryname,
countrycode)
values(46,'Ecuador','EC');
insert
into
country
(id,
countryname,
countrycode)
values(47,'Egypt','EG');
insert
into
country
(id,
countryname,
countrycode)
values(48,'EI
Salvador','SV');
insert
into
country
(id,
countryname,
countrycode)
values(49,'Estonia','EE');
insert
into
country
(id,
countryname,
countrycode)
values(50,'Ethiopia','ET');
insert
into
country
(id,
countryname,
countrycode)
values(51,'Fiji','FJ');
insert
into
country
(id,
countryname,
countrycode)
values(52,'Finland','FI');
insert
into
country
(id,
countryname,
countrycode)
values(53,'France','FR');
insert
into
country
(id,
countryname,
countrycode)
values(54,'French
Guiana','GF');
insert
into
country
(id,
countryname,
countrycode)
values(55,'Gabon','GA');
insert
into
country
(id,
countryname,
countrycode)
values(56,'Gambia','GM');
insert
into
country
(id,
countryname,
countrycode)
values(57,'Georgia','GE');
insert
into
country
(id,
countryname,
countrycode)
values(58,'Germany','DE');
insert
into
country
(id,
countryname,
countrycode)
values(59,'Ghana','GH');
insert
into
country
(id,
countryname,
countrycode)
values(60,'Gibraltar','GI');
insert
into
country
(id,
countryname,
countrycode)
values(61,'Greece','GR');
insert
into
country
(id,
countryname,
countrycode)
values(62,'Grenada','GD');
insert
into
country
(id,
countryname,
countrycode)
values(63,'Guam','GU');
insert
into
country
(id,
countryname,
countrycode)
values(64,'Guatemala','GT');
insert
into
country
(id,
countryname,
countrycode)
values(65,'Guinea','GN');
insert
into
country
(id,
countryname,
countrycode)
values(66,'Guyana','GY');
insert
into
country
(id,
countryname,
countrycode)
values(67,'Haiti','HT');
insert
into
country
(id,
countryname,
countrycode)
values(68,'Honduras','HN');
insert
into
country
(id,
countryname,
countrycode)
values(69,'Hongkong','HK');
insert
into
country
(id,
countryname,
countrycode)
values(70,'Hungary','HU');
insert
into
country
(id,
countryname,
countrycode)
values(71,'Iceland','IS');
insert
into
country
(id,
countryname,
countrycode)
values(72,'India','IN');
insert
into
country
(id,
countryname,
countrycode)
values(73,'Indonesia','ID');
insert
into
country
(id,
countryname,
countrycode)
values(74,'Iran','IR');
insert
into
country
(id,
countryname,
countrycode)
values(75,'Iraq','IQ');
insert
into
country
(id,
countryname,
countrycode)
values(76,'Ireland','IE');
insert
into
country
(id,
countryname,
countrycode)
values(77,'Israel','IL');
insert
into
country
(id,
countryname,
countrycode)
values(78,'Italy','IT');
insert
into
country
(id,
countryname,
countrycode)
values(79,'Jamaica','JM');
insert
into
country
(id,
countryname,
countrycode)
values(80,'Japan','JP');
insert
into
country
(id,
countryname,
countrycode)
values(81,'Jordan','JO');
insert
into
country
(id,
countryname,
countrycode)
values(82,'Kampuchea
(Cambodia
)','KH');
insert
into
country
(id,
countryname,
countrycode)
values(83,'Kazakstan','KZ');
insert
into
country
(id,
countryname,
countrycode)
values(84,'Kenya','KE');
insert
into
country
(id,
countryname,
countrycode)
values(85,'Korea','KR');
insert
into
country
(id,
countryname,
countrycode)
values(86,'Kuwait','KW');
insert
into
country
(id,
countryname,
countrycode)
values(87,'Kyrgyzstan','KG');
insert
into
country
(id,
countryname,
countrycode)
values(88,'Laos','LA');
insert
into
country
(id,
countryname,
countrycode)
values(89,'Latvia','LV');
insert
into
country
(id,
countryname,
countrycode)
values(90,'Lebanon','LB');
insert
into
country
(id,
countryname,
countrycode)
values(91,'Lesotho','LS');
insert
into
country
(id,
countryname,
countrycode)
values(92,'Liberia','LR');
insert
into
country
(id,
countryname,
countrycode)
values(93,'Libya','LY');
insert
into
country
(id,
countryname,
countrycode)
values(94,'Liechtenstein','LI');
insert
into
country
(id,
countryname,
countrycode)
values(95,'Lithuania','LT');
insert
into
country
(id,
countryname,
countrycode)
values(96,'Luxembourg','LU');
insert
into
country
(id,
countryname,
countrycode)
values(97,'Macao','MO');
insert
into
country
(id,
countryname,
countrycode)
values(98,'Madagascar','MG');
insert
into
country
(id,
countryname,
countrycode)
values(99,'Malawi','MW');
insert
into
country
(id,
countryname,
countrycode)
values(100,'Malaysia','MY');
insert
into
country
(id,
countryname,
countrycode)
values(101,'Maldives','MV');
insert
into
country
(id,
countryname,
countrycode)
values(102,'Mali','ML');
insert
into
country
(id,
countryname,
countrycode)
values(103,'Malta','MT');
insert
into
country
(id,
countryname,
countrycode)
values(104,'Mauritius','MU');
insert
into
country
(id,
countryname,
countrycode)
values(105,'Mexico','MX');
insert
into
country
(id,
countryname,
countrycode)
values(106,'Moldova,
Republic
of','MD');
insert
into
country
(id,
countryname,
countrycode)
values(107,'Monaco','MC');
insert
into
country
(id,
countryname,
countrycode)
values(108,'Mongolia','MN');
insert
into
country
(id,
countryname,
countrycode)
values(109,'Montserrat
Is','MS');
insert
into
country
(id,
countryname,
countrycode)
values(110,'Morocco','MA');
insert
into
country
(id,
countryname,
countrycode)
values(111,'Mozambique','MZ');
insert
into
country
(id,
countryname,
countrycode)
values(112,'Namibia','NA');
insert
into
country
(id,
countryname,
countrycode)
values(113,'Nauru','NR');
insert
into
country
(id,
countryname,
countrycode)
values(114,'Nepal','NP');
insert
into
country
(id,
countryname,
countrycode)
values(115,'Netherlands','NL');
insert
into
country
(id,
countryname,
countrycode)
values(116,'New
Zealand','NZ');
insert
into
country
(id,
countryname,
countrycode)
values(117,'Nicaragua','NI');
insert
into
country
(id,
countryname,
countrycode)
values(118,'Niger','NE');
insert
into
country
(id,
countryname,
countrycode)
values(119,'Nigeria','NG');
insert
into
country
(id,
countryname,
countrycode)
values(120,'North
Korea','KP');
insert
into
country
(id,
countryname,
countrycode)
values(121,'Norway','NO');
insert
into
country
(id,
countryname,
countrycode)
values(122,'Oman','OM');
insert
into
country
(id,
countryname,
countrycode)
values(123,'Pakistan','PK');
insert
into
country
(id,
countryname,
countrycode)
values(124,'Panama','PA');
insert
into
country
(id,
countryname,
countrycode)
values(125,'Papua
New
Cuinea','PG');
insert
into
country
(id,
countryname,
countrycode)
values(126,'Paraguay','PY');
insert
into
country
(id,
countryname,
countrycode)
values(127,'Peru','PE');
insert
into
country
(id,
countryname,
countrycode)
values(128,'Philippines','PH');
insert
into
country
(id,
countryname,
countrycode)
values(129,'Poland','PL');
insert
into
country
(id,
countryname,
countrycode)
values(130,'French
Polynesia','PF');
insert
into
country
(id,
countryname,
countrycode)
values(131,'Portugal','PT');
insert
into
country
(id,
countryname,
countrycode)
values(132,'Puerto
Rico','PR');
insert
into
country
(id,
countryname,
countrycode)
values(133,'Qatar','QA');
insert
into
country
(id,
countryname,
countrycode)
values(134,'Romania','RO');
insert
into
country
(id,
countryname,
countrycode)
values(135,'Russia','RU');
insert
into
country
(id,
countryname,
countrycode)
values(136,'Saint
Lueia','LC');
insert
into
country
(id,
countryname,
countrycode)
values(137,'Saint
Vincent','VC');
insert
into
country
(id,
countryname,
countrycode)
values(138,'San
Marino','SM');
insert
into
country
(id,
countryname,
countrycode)
values(139,'Sao
Tome
and
Principe','ST');
insert
into
country
(id,
countryname,
countrycode)
values(140,'Saudi
Arabia','SA');
insert
into
country
(id,
countryname,
countrycode)
values(141,'Senegal','SN');
insert
into
country
(id,
countryname,
countrycode)
values(142,'Seychelles','SC');
insert
into
country
(id,
countryname,
countrycode)
values(143,'Sierra
Leone','SL');
insert
into
country
(id,
countryname,
countrycode)
values(144,'Singapore','SG');
insert
into
country
(id,
countryname,
countrycode)
values(145,'Slovakia','SK');
insert
into
country
(id,
countryname,
countrycode)
values(146,'Slovenia','SI');
insert
into
country
(id,
countryname,
countrycode)
values(147,'Solomon
Is','SB');
insert
into
country
(id,
countryname,
countrycode)
values(148,'Somali','SO');
insert
into
country
(id,
countryname,
countrycode)
values(149,'South
Africa','ZA');
insert
into
country
(id,
countryname,
countrycode)
values(150,'Spain','ES');
insert
into
country
(id,
countryname,
countrycode)
values(151,'Sri
Lanka','LK');
insert
into
country
(id,
countryname,
countrycode)
values(152,'St.Lucia','LC');
insert
into
country
(id,
countryname,
countrycode)
values(153,'St.Vincent','VC');
insert
into
country
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 財務(wù)人員的責(zé)任與義務(wù)計劃
- 制定清晰的財務(wù)目標(biāo)計劃
- 幼兒藝術(shù)表現(xiàn)的多樣性研究計劃
- 萬源市竹源煤業(yè)有限公司長石二煤礦礦山地質(zhì)環(huán)境保護(hù)與土地復(fù)墾方案情況
- 2025年經(jīng)典大班蒙氏數(shù)學(xué)標(biāo)準(zhǔn)教案
- 空乘禮儀知識培訓(xùn)班課件
- 2025年四川貨運(yùn)從業(yè)資格證考試模擬考試答案
- 胃癌治療手段
- 2025年洛陽貨運(yùn)從業(yè)資格證考試技巧
- 3D打印技術(shù)知到課后答案智慧樹章節(jié)測試答案2025年春上海電子信息職業(yè)技術(shù)學(xué)院
- 辦公用品供貨服務(wù)計劃方案
- DB37∕T 5107-2018 城鎮(zhèn)排水管道檢測與評估技術(shù)規(guī)程
- 2022新冠疫苗疑似預(yù)防接種異常反應(yīng)監(jiān)測和處置方案
- 酒精溶液體積濃度、質(zhì)量濃度與密度對照表
- 主要腸內(nèi)營養(yǎng)制劑成分比較
- 老年人各系統(tǒng)的老化改變
- 小學(xué)五年級綜合實(shí)踐課教案
- 煤礦井下供電常用計算公式及系數(shù)
- ISO14001:2015中文版(20211205141421)
- 汽車總裝車間板鏈輸送線的應(yīng)用研究
- 工作日志模板
評論
0/150
提交評論