In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you about how to use Jpa to achieve paging function in springboot, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
Springboot integrates Jpa to realize pagination
Since the technology used is not complicated, let's get to the point and go straight to the code.
Let's take a look at the code structure first.
Pom.xml introduces related jar package 4.0.0 org.springframework.boot spring-boot-starter-parent 2.3.4.RELEASE com.example springboot-blog 0.0.1-SNAPSHOT springboot-blog Blog project for Spring Boot 1.8 org.springframework.boot spring-boot-starter-data-jpa Org.springframework.boot spring-boot-starter-thymeleaf org.springframework.boot spring-boot-starter-web junit junit mysql mysql-connector-java runtime Org.projectlombok lombok true org.springframework.boot spring-boot-starter-test test org.junit.vintage junit-vintage-engine Org.springframework.boot spring-boot-maven-plugin application.properties configuration # configure data Source spring.datasource.url=jdbc:mysql://localhost:3306/blog_systemspring.datasource.username=rootspring.datasource.password=root# basic configuration spring.application.name=springboot-blogserver.port=8080# display sqlspring.jpa.show-sql=true entity class Article@Data@ToString@Entity@Table (name = "t_article") public class Article {@ Id private Integer id @ Column (name = "title") private String title; @ Column (name = "content") private String content; @ Column (name = "created") private Date created; @ Column (name = "modified") private Date modified; @ Column (name = "categories") private String categories; @ Column (name = "tags") private String tags; @ Column (name = "allow_comment") private Integer allowComment @ Column (name = "thumbnail") private String thumbnail;} ArticleDao layer implements public interface ArticleDao extends JpaRepository {} ArticleService layer ArticleService interface public interface ArticleService {Page getArticleWithPage (Integer page, Integer size);} ArticleServiceImpl implementation class @ Service@Slf4jpublic class ArticleServiceImpl implements ArticleService {@ Autowired private ArticleDao articleDao; @ Override public Page getArticleWithPage (Integer page, Integer size) {log.info ("page is {}, size is {}", page, size); if (page
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.