当前位置: 首页 > news >正文

黄冈网站排名最高南宁百度seo推广

黄冈网站排名最高,南宁百度seo推广,seo技术培训宁波,东莞疫情数据spring-boot-data-jpa、JPA实现分页 JPA越来越丰富了,下面使用springboot3.x实现JPA分页 通过传入PageRequest pageRequest PageRequest.of(page, size);到接口查询,返回Page拿到分页数据。 转自 https://lingkang.top/archives/jpa-shi-xian-fen-ye …

spring-boot-data-jpa、JPA实现分页

JPA越来越丰富了,下面使用springboot3.x实现JPA分页

通过传入PageRequest pageRequest = PageRequest.of(page, size);到接口查询,返回Page拿到分页数据。

转自 https://lingkang.top/archives/jpa-shi-xian-fen-ye

依赖

		<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-jpa</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-security</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>com.mysql</groupId><artifactId>mysql-connector-j</artifactId><scope>runtime</scope></dependency>

数据库配置

spring.jpa.show-sql=true
spring.jpa.open-in-view=false
spring.jpa.hibernate.ddl-auto=update
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnicode=true&nullCatalogMeansCurrent=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.poolName=db1

启动类

@SpringBootApplication
@EnableJpaRepositories("top.lingkang.lingdongmall.repository")
@EntityScan("top.lingkang.lingdongmall.entity")
public class LingdongMallApplication {public static void main(String[] args) {SpringApplication.run(LingdongMallApplication.class, args);}}

接口

public interface GoodsRepository extends JpaRepository<GoodsEntity, String> {@Query("select e from GoodsClassifyEntity c left join GoodsEntity e on e.id=c.goodsId " +"where c.classifyId=?1 and c.level=?2")Page<GoodsEntity> goods(String classifyId, String level, Pageable pageable);
}

调用

    public ResponseResultPage goods(String classifyId, String level, Integer page, Integer size) {// 注意,page分页是从0开始计算的,0=第一页PageRequest pageRequest = PageRequest.of(page, size);Page<GoodsEntity> goods = goodsRepository.goods(classifyId, level, pageRequest);return new ResponseResultPage().setPage(page).setSize(size).setTotal(goods.getTotalElements()) // 分页总数.setData(goods.getContent()); // 分页查询到内容}
http://www.ds6.com.cn/news/96352.html

相关文章:

  • 如何建设公司网络营销网站网站结构优化的内容和方法
  • 上海网站制作计划新浪博客seo
  • 域名与网站区别免费的个人主页网页制作网站
  • 网站国际化建设方案推广优化方案
  • 网络平台制作方法优质的seo快速排名优化
  • vs2012做网站百度一下百度
  • 网站开发心得500字今天最新的新闻头条
  • wordpress站点后台百度收录技术
  • 钟表珠宝商城网站建设搜索引擎优化是什么工作
  • 档案网站建设的原则软文广告300字范文
  • 惠州住房和城乡建设厅网站网络客服
  • 如何检查网站死链在线域名解析ip地址
  • c 博客网站开发教程北京百度seo关键词优化
  • wordpress页面都在右边北京网站优化对策
  • 一起做业官方网站拓客团队怎么联系
  • 网站后台代码在哪修改seo顾问阿亮博客
  • wordpress 春菜隐藏郑州seo管理
  • 建设工程信息哪个网站有详细信息百度广告公司联系方式
  • 青岛国家高新区建设局网站百度人工智能开放平台
  • 山东省交通运输厅网站开发单位优化关键词软件
  • 大芬地铁站附近做网站网络营销活动推广方式
  • 单位做网站费用怎么记账怎么给产品做网络推广
  • 网络优化培训老铁seo外链工具
  • 苏州 网站建设百度seo 站长工具
  • 杭州政府网站建设管理办法公司做网络推广哪个网站好
  • 合肥专业手机网站哪家好电商平台建设方案
  • 自考大型网站开发工具sem优化软件选哪家
  • 如何java做网站seo查询排名软件
  • 淄博网站建设报价深圳seo关键词优化
  • 网站建设大概要多少钱口碑优化seo