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

有哪些做网站的网站网站域名在哪买

有哪些做网站的网站,网站域名在哪买,小榄网站建设公司,seo优化器无论多数据源,还是单数据源,分页都一样,刚开始出了点错,是因为PageHelper的版本问题 这里用的SpringBoot3 SpringBoot2应该是没有问题的 相关代码 dynamic-datasourceMybatis多数据源使用-CSDN博客 依赖 <?xml version"1.0" encoding"UTF-8"?&g…

无论多数据源,还是单数据源,分页都一样,刚开始出了点错,是因为PageHelper的版本问题

这里用的SpringBoot3    SpringBoot2应该是没有问题的

相关代码

dynamic-datasource+Mybatis多数据源使用-CSDN博客

依赖

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>3.2.8</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.example</groupId><artifactId>dynamic-datasource</artifactId><version>0.0.1-SNAPSHOT</version><name>dynamic-datasource</name><description>Demo project for Spring Boot</description><url/><licenses><license/></licenses><developers><developer/></developers><scm><connection/><developerConnection/><tag/><url/></scm><properties><java.version>17</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>3.0.3</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.33</version></dependency><!--dynamic-datasource --><dependency><groupId>com.baomidou</groupId><artifactId>dynamic-datasource-spring-boot3-starter</artifactId><version>4.3.1</version></dependency><dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-starter</artifactId><version>1.2.21</version></dependency><!--分页 低版本要自己额外配置下 -->
<!--        <dependency>-->
<!--            <groupId>com.github.pagehelper</groupId>-->
<!--            <artifactId>pagehelper-spring-boot-starter</artifactId>-->
<!--            <version>1.3.1</version>-->
<!--        </dependency>--><dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper-spring-boot-starter</artifactId><version>2.1.0</version></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><excludes><exclude><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></exclude></excludes></configuration></plugin></plugins></build></project>

PageHelper配置

#PageHelper 配置
#推荐明确指定数据库方言
pagehelper.helperDialect=mysql
#合理化分页参数,避免异常页码导致的错误  启用后,当 pageNum 小于等于 0 时,会自动查询第一页的数据;当 pageNum 大于总页数时,会自动查询最后一页的数据。
pagehelper.reasonable=true
#支持通过方法参数传递分页参数  PageHelper.startPage(1,2)
pagehelper.supportMethodsArguments=true
#自动生成 count 查询语句用于计算总记录数(默认配置)
pagehelper.params=count=countSql
#在运行时自动识别和设置数据库方言
#pagehelper.autoRuntimeDialect=true

持久层   PageHelper会拦截sql  拼接 select * from xxx limit (pageNum-1)*pageSize,pageSize

如果非要在SpringBoot3使用低版本PageHelper

package com.example.dynamicdatasource.config;import com.github.pagehelper.PageInterceptor;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;import javax.sql.DataSource;
import java.util.Properties;/*** @author hrui* @date 2024/8/6 21:03*/
@Configuration
public class MyBatisConfig {/*因使用的SpringBoot3  低版本PageHelp要额外配置   application.properties中的pageHelp无法set到参数  高版本没有问题 不需要设置*/
//    @Bean
//    public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
//        org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration();
//        SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
//        factoryBean.setDataSource(dataSource);
//
//        // 添加PageHelper分页插件
//        PageInterceptor pageInterceptor = new PageInterceptor();
//        Properties properties = new Properties();
//        properties.setProperty("helperDialect", "mysql");
//        properties.setProperty("reasonable", "true");
//        properties.setProperty("supportMethodsArguments", "true");
//        properties.setProperty("params", "count=countSql");
//        pageInterceptor.setProperties(properties);
//
//        configuration.addInterceptor(pageInterceptor);
//        factoryBean.setConfiguration(configuration);
//        return factoryBean.getObject();
//    }
}

http://www.shuangfujiaoyu.com/news/28600.html

相关文章:

  • 中国制造网注册网站免费注册厦门seo排名收费
  • 芒果国际影城星沙店桔子seo网
  • 网站项目方案公司网站设计模板
  • 公司建网站多少钱成人用品推广网页
  • 网站的项目建设周期长尾关键词排名系统
  • 外贸汽车网站制作网站优化排名软件
  • 服务器可以做网站如何写软文赚钱
  • 怎样用编程语言做网站百度推广app怎么收费
  • 做网站页面的软件刷僵尸粉网站推广
  • 网站的访问量网站seo优化免费
  • 政府网站建设工作会议上的讲话南昌seo排名公司
  • 杭州号码百事通做网站网络加速器
  • cms网站管理北京网站推广排名外包
  • 素材网站模板网站建设优化哪家公司好
  • 广西住建局官方网站新浪nba最新消息
  • 网站设计收费标准奶糖 seo 博客
  • 怎么做网站的内链外链seo搜索引擎优化试题
  • 吉粤建设工程股份有限公司网站云南seo网站关键词优化软件
  • vps利用端口做不同网站今日重大新闻头条十条
  • 赣州那里有做网站的公司自动点击器怎么用
  • 做外贸网站租什么服务器网店运营培训
  • 通辽市城乡建设局网站企业网站模板下载
  • 济南营销型网站建设天津seo优化公司
  • 广西住房和城乡建设厅继续教育网seo公司排行
  • 成都市营销型网站建设南宁网站推广大全
  • 建站快车用户登录网络营销的基本方式有哪些
  • 搜索不到网站的关键词合肥网络关键词排名
  • wordpress视频无画面搜索引擎排名优化seo
  • 做购物网站多少钱免费设计模板网站
  • 哪个网站可以做翻译赚钱郑州百度seo