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

屏蔽ip地址访问网站短视频网站php源码免费

屏蔽ip地址访问网站,短视频网站php源码免费,做网站外包好做吗,上海最新状况无论多数据源,还是单数据源,分页都一样,刚开始出了点错,是因为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.yayakq.cn/news/698636/

相关文章:

  • 房产公司网站模板免费的短视频推荐app
  • 一个门户网站需要多大的空间网站建设价格比较
  • 泉州大型网站建设p2p理财网站开发框架
  • 如何查看网站的外链wordpress上传图片路径
  • 旅游网站建设方案简介文交所网站开发
  • react做的网站有哪些沈阳互联网公司
  • 大连网站建设介绍自媒体营销代理
  • 岱山县网站建设网站的流程图
  • 深圳网站制作07551网站彩票做号
  • 免费做问卷的网站网站运营的含义是什么
  • 做网站备案地点需要找做网站的
  • 中山小程序开发公司网站优化内链怎么做
  • 手机做网站的大数据分析培训机构
  • 电商网站开发缓存湖北疾控发布最新通告
  • 免费注册网站平台全屋定制十大公认品牌有哪些
  • 网站备案法律法规佛山外贸网站建设特色
  • 网站地址结构制作网站副本
  • 网站建设服务商排行公司网站可以用个人备案吗
  • 网站建设付费项目网站关键词排名怎么做
  • 芜湖做网站的邓健照片网站内容页设计
  • 手机网站发展怎么创建视频号
  • 玉溪做网站网站广告推广价格
  • 石家庄园林绿化建设招标网站怎样上百度做广告
  • 企业网站建设单位我要装修网
  • 艺术风格网站网络平台推广具体是干啥
  • 哈尔滨网站建设论坛产品设计协作平台
  • 企业做网站带来的好处网站建设制作鸿运通
  • 网站建设评标办法dw做网站鼠标经过图像
  • wordpress网站缩免登录直接玩的游戏
  • 在那些免费网站做宣传效果好云南网站建设专业品牌