spring boot with integrated mybatis plus pages full tutorial

First, add dependencies

        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.2.0</version>
        </dependency>

Two, spring boot configuration

server.port=8797
# Queue length, the default is 100
server.tomcat.accept-count=100
The maximum number of connections can be #
server.tomcat.max-connections=10000
# Maximum number of threads
server.tomcat.max-threads=200
# The minimum number of threads
server.tomcat.min-spare-threads=10

spring.application.name=/

spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2B8
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=root

spring.datasource.hikari.connection-test-query=select 1
spring.datasource.hikari.read-only=false
spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.idle-timeout=600000
spring.datasource.hikari.max-lifetime=60000
spring.datasource.hikari.maximum-pool-size=10

mybatis-plus.mapper-locations=classpath*:/mapper/**/*.xml
mybatis-plus.type-aliases-package=com.mz.mzservice.*.entity
mybatis-plus.type-aliases-super-type=com.mz.mzservice.entity.BaseEntity
mybatis-plus.global-config.banner=false

Three, mybatis plus configuration contains the page

Adding a configuration class

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@EnableTransactionManagement
@Configuration
@MapperScan("com.mz.mzservice.*.mapper")
public class MybatisPlusConfig {

    @Bean
    public PaginationInterceptor paginationInterceptor () {
        PaginationInterceptor PaginationInterceptor = new new PaginationInterceptor ();
         // After setting the requested page is greater than the maximum operating page, true transferred back home, false continue to request the default false
         // paginationInterceptor.setOverflow (false);
         // set the maximum number of single-page limit, default 500, unrestricted -1
         // paginationInterceptor.setLimit (500); 
        return paginationInterceptor;
    }
}

 

You get, are pleasant to use.

I have another article with code generation article  https://www.cnblogs.com/enenen/p/11704351.html  can get started faster.

Guess you like

Origin www.cnblogs.com/enenen/p/11704471.html