逻辑删除与分页插件怎么在MyBatis +中使用

  介绍

逻辑删除与分页插件怎么在MyBatis +中使用?很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。

<强>一、依赖配置:

& lt;及# 63;xml version=?.0”;编码=癠TF-8", # 63;比;   http://maven.apache.org/POM/4.0.0" & lt;项目xmlns=?xmlns: xsi=癶ttp://www.w3.org/2001/XMLSchema-instance"   ,xsi: schemaLocation=癶ttp://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"的在;   & lt; modelVersion> 4.0.0   & lt; parent>   & lt; groupId> org.springframework.boot   & lt; artifactId> spring-boot-starter-parent   & lt; version> 2.2.6.RELEASE   & lt; relativePath/比;& lt; !——从库中查找父——比;   & lt;/parent>   & lt; groupId> com.example   & lt; artifactId> demo   & lt; version> 0.0.1-SNAPSHOT   & lt; name> demo   春天Boot< & lt; description>演示项目;/description>      & lt; properties>   & lt; java.version> 1.8 & lt;/java.version>   & lt;/properties>      & lt; dependencies>   & lt; dependency>   & lt; groupId> org.springframework.boot   & lt; artifactId> spring-boot-starter-web   & lt;/dependency>      & lt; dependency>   & lt; groupId> mysql   & lt; artifactId> mysql-connector-java   & lt; scope> runtime   & lt;/dependency>   & lt; dependency>   & lt; groupId> org.projectlombok   & lt; artifactId> lombok   & lt; optional> true   & lt;/dependency>   & lt; dependency>   & lt; groupId> com.baomidou   & lt; artifactId> mybatisplus-spring-boot-starter   & lt; version> 1.0.5   & lt;/dependency>   & lt; dependency>   & lt; groupId> org.springframework.boot   & lt; artifactId> spring-boot-starter-test   & lt; scope> test   & lt; exclusions>   & lt; exclusion>   & lt; groupId> org.junit.vintage   & lt; artifactId> junit-vintage-engine   & lt;/exclusion>   & lt;/exclusions>   & lt;/dependency>   & lt; dependency>   & lt; groupId> com.baomidou   & lt; artifactId> mybatis-plus   & lt; version> 3.3.1   & lt;/dependency>   & lt;/dependencies>      & lt; build>   & lt; plugins>   & lt; plugin>   & lt; groupId> org.springframework.boot   & lt; artifactId> spring-boot-maven-plugin   & lt;/plugin>   & lt;/plugins>   & lt;/build>      & lt;/project>

<强>二、数据源和插件相关配置

<强>——应用程序。yml

服务器:   端口:8080   servlet:   上下文路径:/#日志配置   日志:   水平:   com.baomidou.mybatisplus.samples。快速入门:调试

<强> - db。属性

spring.datasource。jdbc url=jdbc: mysql://localhost: 3306/demo& # 63; serverTimezone=UTC& characterEncoding=utf8   spring.datasource。用户名=根   spring.datasource。密码=123456   spring.datasource。driverClassName=com.mysql.cj.jdbc。司机

<强> - MybatisPlusConfig

包com.example.demo.config;
  
  进口com.baomidou.mybatisplus.annotation.DbType;
  进口com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
  进口com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize;
  进口org.mybatis.spring.annotation.MapperScan;
  进口org.springframework.context.annotation.Bean;
  进口org.springframework.context.annotation.Configuration;
  进口org.springframework.transaction.annotation.EnableTransactionManagement;
  
  @EnableTransactionManagement
  @ configuration
  @MapperScan (“com.example.demo.mapper")
  公开课MybatisPlusConfig {
  
  @ bean (“paginationInterceptor")
  公共PaginationInterceptor PaginationInterceptor () {
  PaginationInterceptor PaginationInterceptor=new PaginationInterceptor ();
  paginationInterceptor。setCountSqlParser(新JsqlParserCountOptimize (true));
  paginationInterceptor.setDbType (DbType.MYSQL);
  返回paginationInterceptor;
  }
  }

<强> - SqlSessionConfig

包com.example.demo.config;
  
  进口com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
  进口com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
  
  进口org.apache.ibatis.plugin.Interceptor;
  进口org.mybatis.spring.mapper.MapperScannerConfigurer;
  进口org.slf4j.Logger;
  进口org.slf4j.LoggerFactory;
  进口org.springframework.beans.factory.annotation.Qualifier;
  进口org.springframework.boot.context.properties.ConfigurationProperties;
  进口org.springframework.boot.jdbc.DataSourceBuilder;
  进口org.springframework.context.annotation.Bean;
  进口org.springframework.context.annotation.Configuration;
  进口org.springframework.context.annotation.PropertySource;
  进口org.springframework.core.io.support.PathMatchingResourcePatternResolver;
  进口javax.sql.DataSource;
  
  @ configuration
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null

逻辑删除与分页插件怎么在MyBatis +中使用