使用Spring Boot双数据源和PageHelper实现无缝分页查询

在开发中,有时我们需要使用多个数据源来访问不同的数据库。而在分页查询时,我们希望能够方便地使用PageHelper插件来处理结果集的分页逻辑。通过结合Spring Boot的双数据源功能和PageHelper的Spring Boot Starter,我们可以实现简单且高效的分页查询。

在这个功能组合中,Spring Boot的双数据源功能允许我们配置和管理多个数据源,使得我们可以轻松地访问多个数据库。而PageHelper的Spring Boot Starter则提供了与Spring Boot集成的便捷方式,自动配置了PageHelper插件,并与双数据源功能无缝集成。

通过使用这个组合,我们可以使用PageHelper提供的分页插件来处理双数据源的查询结果,以实现分页功能。我们只需要在相应的数据源上配置PageHelper的属性,然后在查询方法中使用PageHelper提供的分页方法,即可轻松地进行分页查询操作。

【重点】在多个数据源中不同的数据库分页的sql语句不一样,MySQL使用limit,Oracle使用rownum,而PageHelper为我们提供了方便,只要配置属性autoRuntimeDialecttrue就可以完全支持不同类型数据库数据源分页了,为了实现该功能有三种方式

1、添加依赖

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><version>2.6.11</version>
</dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-aop</artifactId><version>2.6.11</version>
</dependency>
<!-- pagehelper -->
<dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper-spring-boot-starter</artifactId><version>1.4.2</version>
</dependency>
<!-- mybatis -->
<dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>2.2.2</version>
</dependency>
<!-- mysql -->
<dependency><groupId>com.mysql</groupId><artifactId>mysql-connector-j</artifactId><version>8.3.0</version>
</dependency>
<!-- oracle-->
<dependency><groupId>com.oracle.ojdbc</groupId><artifactId>ojdbc8</artifactId><version>19.3.0.0</version>
</dependency>

2、不同类型数据库多数据源处理方式

SqlSessionFactoryBean时使用了PageInterceptor插件,并设置"helperDialect",值为不同数据库方言:properties.setProperty("helperDialect", "数据库方言");这样的方式能达到不同数据源分页的效果

2.1、不同的数据源使用不同的PageInterceptor过滤

2.1.1、主数据源配置

package com.hssa.shrimppaste.config;import com.github.pagehelper.PageInterceptor;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;import javax.sql.DataSource;
import java.util.Properties;/*** 主数据源配置** @author 虾酱* @since 2024/4/24*/
@Configuration
@MapperScan(basePackages = "com.hssa.shrimppaste.mapper.primary", sqlSessionTemplateRef = "primarySqlSessionTemplate")
public class PrimaryDataSourceConfig {/*** 主数据源配置* * @author 虾酱* @since 2024/4/24* @return 主数据源*/@Primary@Bean(name = "primaryDataSource")@ConfigurationProperties(prefix = "spring.datasource.primary")public DataSource primaryDataSource() {return DataSourceBuilder.create().build();}/*** 创建SqlSessionFactory数据库会话对象* * @author 虾酱* @since 2024/4/24* @param dataSource 数据源* @return SqlSessionFactory对象*/@Primary@Bean(name = "primarySqlSessionFactory")public SqlSessionFactory primarySqlSessionFactory(@Qualifier("primaryDataSource") DataSource dataSource)throws Exception {SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();// 设置数据源sqlSessionFactoryBean.setDataSource(dataSource);PageInterceptor pageInterceptor = new PageInterceptor();Properties properties = new Properties();properties.setProperty("helperDialect", "oracle");pageInterceptor.setProperties(properties);sqlSessionFactoryBean.setPlugins(pageInterceptor);// 设置Mapper文件的位置sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResource("classpath:config/mappers/primary/**/*.xml"));return sqlSessionFactoryBean.getObject();}/*** 创建DataSourceTransactionManager数据源事务管理器* * @author 虾酱* @since 2024/4/24* @param dataSource 数据源* @return DataSourceTransactionManager对象*/@Primary@Bean(name = "primaryTransactionManager")public DataSourceTransactionManager primaryTransactionManager(@Qualifier("primaryDataSource") DataSource dataSource) {return new DataSourceTransactionManager(dataSource);}/*** 创建SqlSessionTemplate数据库会话模板** @author 虾酱* @since 2024/4/24* @param sqlSessionFactory sqlSessionFactory* @return SqlSessionTemplate对象*/@Primary@Bean(name = "primarySqlSessionTemplate")public SqlSessionTemplate primarySqlSessionTemplate(@Qualifier("primarySqlSessionFactory") SqlSessionFactory sqlSessionFactory) {return new SqlSessionTemplate(sqlSessionFactory);}
}

2.1.2、辅助数据源配置

package com.hssa.shrimppaste.config;import com.github.pagehelper.PageInterceptor;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;import javax.sql.DataSource;
import java.util.Properties;/*** 辅助数据源配置** @author 虾酱* @since 2024/4/24*/
@Configuration
@MapperScan(basePackages = "com.hssa.shrimppaste.mapper.secondary", sqlSessionTemplateRef = "secondarySqlSessionTemplate")
public class SecondaryDataSourceConfig {/*** 主数据源配置* * @author 虾酱* @since 2024/4/24* @return 主数据源*/@Bean(name = "secondaryDataSource")@ConfigurationProperties(prefix = "spring.datasource.secondary")public DataSource secondaryDataSource() {return DataSourceBuilder.create().build();}/*** 创建SqlSessionFactory数据库会话对象* * @author 虾酱* @since 2024/4/24* @param dataSource 数据源* @return SqlSessionFactory对象*/@Bean(name = "secondarySqlSessionFactory")public SqlSessionFactory secondarySqlSessionFactory(@Qualifier("secondaryDataSource") DataSource dataSource)throws Exception {SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();// 设置数据源sqlSessionFactoryBean.setDataSource(dataSource);PageInterceptor pageInterceptor = new PageInterceptor();Properties properties = new Properties();properties.setProperty("helperDialect", "mysql");pageInterceptor.setProperties(properties);sqlSessionFactoryBean.setPlugins(pageInterceptor);// 设置Mapper文件的位置sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResource("classpath:config/mappers/secondary/**/*.xml"));return sqlSessionFactoryBean.getObject();}/*** 创建DataSourceTransactionManager数据源事务管理器* * @author 虾酱* @since 2024/4/24* @param dataSource 数据源* @return DataSourceTransactionManager对象*/@Bean(name = "secondaryTransactionManager")public DataSourceTransactionManager secondaryTransactionManager(@Qualifier("secondaryDataSource") DataSource dataSource) {return new DataSourceTransactionManager(dataSource);}/*** 创建SqlSessionTemplate数据库会话模板** @author 虾酱* @since 2024/4/24* @param sqlSessionFactory sqlSessionFactory* @return SqlSessionTemplate对象*/@Bean(name = "secondarySqlSessionTemplate")public SqlSessionTemplate secondarySqlSessionTemplate(@Qualifier("secondarySqlSessionFactory") SqlSessionFactory sqlSessionFactory) {return new SqlSessionTemplate(sqlSessionFactory);}
}

2.2、统一配置PageInterceptor

2.2.1、统一配置

  @Configurationpublic class PageHelperConfig {@BeanPageInterceptor pageInterceptor() {PageInterceptor pageInterceptor = new PageInterceptor();Properties properties = new Properties();// 处理多数据源 properties.setProperty("autoRuntimeDialect", "true");pageInterceptor.setProperties(properties);return pageInterceptor;}}

2.2.2、主数据源配置

package com.hssa.shrimppaste.config;import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;import javax.sql.DataSource;/*** 主数据源配置** @author 虾酱* @since 2024/4/24*/
@Configuration
@MapperScan(basePackages = "com.hssa.shrimppaste.mapper.primary", sqlSessionTemplateRef = "primarySqlSessionTemplate")
public class PrimaryDataSourceConfig {/*** 主数据源配置* * @author 虾酱* @since 2024/4/24* @return 主数据源*/@Primary@Bean(name = "primaryDataSource")@ConfigurationProperties(prefix = "spring.datasource.primary")public DataSource primaryDataSource() {return DataSourceBuilder.create().build();}/*** 创建SqlSessionFactory数据库会话对象* * @author 虾酱* @since 2024/4/24* @param dataSource 数据源* @return SqlSessionFactory对象*/@Primary@Bean(name = "primarySqlSessionFactory")public SqlSessionFactory primarySqlSessionFactory(@Qualifier("primaryDataSource") DataSource dataSource)throws Exception {SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();// 设置数据源sqlSessionFactoryBean.setDataSource(dataSource);// 设置Mapper文件的位置sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResource("classpath:config/mappers/primary/**/*.xml"));return sqlSessionFactoryBean.getObject();}/*** 创建DataSourceTransactionManager数据源事务管理器* * @author 虾酱* @since 2024/4/24* @param dataSource 数据源* @return DataSourceTransactionManager对象*/@Primary@Bean(name = "primaryTransactionManager")public DataSourceTransactionManager primaryTransactionManager(@Qualifier("primaryDataSource") DataSource dataSource) {return new DataSourceTransactionManager(dataSource);}/*** 创建SqlSessionTemplate数据库会话模板** @author 虾酱* @since 2024/4/24* @param sqlSessionFactory sqlSessionFactory* @return SqlSessionTemplate对象*/@Primary@Bean(name = "primarySqlSessionTemplate")public SqlSessionTemplate primarySqlSessionTemplate(@Qualifier("primarySqlSessionFactory") SqlSessionFactory sqlSessionFactory) {return new SqlSessionTemplate(sqlSessionFactory);}
}

2.2.3、辅助数据源配置

package com.hssa.shrimppaste.config;import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;import javax.sql.DataSource;/*** 辅助数据源配置** @author 虾酱* @since 2024/4/24*/
@Configuration
@MapperScan(basePackages = "com.hssa.shrimppaste.mapper.secondary", sqlSessionTemplateRef = "secondarySqlSessionTemplate")
public class SecondaryDataSourceConfig {/*** 主数据源配置* * @author 虾酱* @since 2024/4/24* @return 主数据源*/@Bean(name = "secondaryDataSource")@ConfigurationProperties(prefix = "spring.datasource.secondary")public DataSource secondaryDataSource() {return DataSourceBuilder.create().build();}/*** 创建SqlSessionFactory数据库会话对象* * @author 虾酱* @since 2024/4/24* @param dataSource 数据源* @return SqlSessionFactory对象*/@Bean(name = "secondarySqlSessionFactory")public SqlSessionFactory secondarySqlSessionFactory(@Qualifier("secondaryDataSource") DataSource dataSource)throws Exception {SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();// 设置数据源sqlSessionFactoryBean.setDataSource(dataSource);// 设置Mapper文件的位置sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResource("classpath:config/mappers/secondary/**/*.xml"));return sqlSessionFactoryBean.getObject();}/*** 创建DataSourceTransactionManager数据源事务管理器* * @author 虾酱* @since 2024/4/24* @param dataSource 数据源* @return DataSourceTransactionManager对象*/@Bean(name = "secondaryTransactionManager")public DataSourceTransactionManager secondaryTransactionManager(@Qualifier("secondaryDataSource") DataSource dataSource) {return new DataSourceTransactionManager(dataSource);}/*** 创建SqlSessionTemplate数据库会话模板** @author 虾酱* @since 2024/4/24* @param sqlSessionFactory sqlSessionFactory* @return SqlSessionTemplate对象*/@Bean(name = "secondarySqlSessionTemplate")public SqlSessionTemplate secondarySqlSessionTemplate(@Qualifier("secondarySqlSessionFactory") SqlSessionFactory sqlSessionFactory) {return new SqlSessionTemplate(sqlSessionFactory);}
}

2.3、配置PageHelper支持多数据源

2.3.1、配置开启支持多数据源

  pagehelper:autoRuntimeDialect: true

2.3.2、主数据源配置

package com.hssa.shrimppaste.config;import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;import javax.sql.DataSource;/*** 主数据源配置** @author 虾酱* @since 2024/4/24*/
@Configuration
@MapperScan(basePackages = "com.hssa.shrimppaste.mapper.primary", sqlSessionTemplateRef = "primarySqlSessionTemplate")
public class PrimaryDataSourceConfig {/*** 主数据源配置* * @author 虾酱* @since 2024/4/24* @return 主数据源*/@Primary@Bean(name = "primaryDataSource")@ConfigurationProperties(prefix = "spring.datasource.primary")public DataSource primaryDataSource() {return DataSourceBuilder.create().build();}/*** 创建SqlSessionFactory数据库会话对象* * @author 虾酱* @since 2024/4/24* @param dataSource 数据源* @return SqlSessionFactory对象*/@Primary@Bean(name = "primarySqlSessionFactory")public SqlSessionFactory primarySqlSessionFactory(@Qualifier("primaryDataSource") DataSource dataSource)throws Exception {SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();// 设置数据源sqlSessionFactoryBean.setDataSource(dataSource);// 设置Mapper文件的位置sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResource("classpath:config/mappers/primary/**/*.xml"));return sqlSessionFactoryBean.getObject();}/*** 创建DataSourceTransactionManager数据源事务管理器* * @author 虾酱* @since 2024/4/24* @param dataSource 数据源* @return DataSourceTransactionManager对象*/@Primary@Bean(name = "primaryTransactionManager")public DataSourceTransactionManager primaryTransactionManager(@Qualifier("primaryDataSource") DataSource dataSource) {return new DataSourceTransactionManager(dataSource);}/*** 创建SqlSessionTemplate数据库会话模板** @author 虾酱* @since 2024/4/24* @param sqlSessionFactory sqlSessionFactory* @return SqlSessionTemplate对象*/@Primary@Bean(name = "primarySqlSessionTemplate")public SqlSessionTemplate primarySqlSessionTemplate(@Qualifier("primarySqlSessionFactory") SqlSessionFactory sqlSessionFactory) {return new SqlSessionTemplate(sqlSessionFactory);}
}

2.3.3、辅助数据源配置

package com.hssa.shrimppaste.config;import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;import javax.sql.DataSource;/*** 辅助数据源配置** @author 虾酱* @since 2024/4/24*/
@Configuration
@MapperScan(basePackages = "com.hssa.shrimppaste.mapper.secondary", sqlSessionTemplateRef = "secondarySqlSessionTemplate")
public class SecondaryDataSourceConfig {/*** 主数据源配置* * @author 虾酱* @since 2024/4/24* @return 主数据源*/@Bean(name = "secondaryDataSource")@ConfigurationProperties(prefix = "spring.datasource.secondary")public DataSource secondaryDataSource() {return DataSourceBuilder.create().build();}/*** 创建SqlSessionFactory数据库会话对象* * @author 虾酱* @since 2024/4/24* @param dataSource 数据源* @return SqlSessionFactory对象*/@Bean(name = "secondarySqlSessionFactory")public SqlSessionFactory secondarySqlSessionFactory(@Qualifier("secondaryDataSource") DataSource dataSource)throws Exception {SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();// 设置数据源sqlSessionFactoryBean.setDataSource(dataSource);// 设置Mapper文件的位置sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResource("classpath:config/mappers/secondary/**/*.xml"));return sqlSessionFactoryBean.getObject();}/*** 创建DataSourceTransactionManager数据源事务管理器* * @author 虾酱* @since 2024/4/24* @param dataSource 数据源* @return DataSourceTransactionManager对象*/@Bean(name = "secondaryTransactionManager")public DataSourceTransactionManager secondaryTransactionManager(@Qualifier("secondaryDataSource") DataSource dataSource) {return new DataSourceTransactionManager(dataSource);}/*** 创建SqlSessionTemplate数据库会话模板** @author 虾酱* @since 2024/4/24* @param sqlSessionFactory sqlSessionFactory* @return SqlSessionTemplate对象*/@Bean(name = "secondarySqlSessionTemplate")public SqlSessionTemplate secondarySqlSessionTemplate(@Qualifier("secondarySqlSessionFactory") SqlSessionFactory sqlSessionFactory) {return new SqlSessionTemplate(sqlSessionFactory);}
}



【总结】:Spring Boot的双数据源功能和PageHelper的Spring Boot Starter来实现多数据源的分页查询,需要配置PageHelper的"autoRuntimeDialect"属性为true

在类PageAutoDialect方法setProperties中动态多数据源分支明确表示需要配置autoRuntimeDialect,如未配置则不会认为是多数据源,HelperDialect 方言永远是第一次查询时的方言,当第一次查询MySQL再次查询Oracle分页时候则会使用MySQL分页方式给Oracle分页,这显然不是我们想要的。

public void setProperties(Properties properties) {//初始化自定义AutoDialectinitAutoDialectClass(properties);//使用 sqlserver2012 作为默认分页方式,这种情况在动态数据源时方便使用String useSqlserver2012 = properties.getProperty("useSqlserver2012");if (StringUtil.isNotEmpty(useSqlserver2012) && Boolean.parseBoolean(useSqlserver2012)) {registerDialectAlias("sqlserver", SqlServer2012Dialect.class);registerDialectAlias("sqlserver2008", SqlServerDialect.class);}initDialectAlias(properties);//指定的 Helper 数据库方言,和  不同String dialect = properties.getProperty("helperDialect");//运行时获取数据源String runtimeDialect = properties.getProperty("autoRuntimeDialect");//1.动态多数据源if (StringUtil.isNotEmpty(runtimeDialect) && "TRUE".equalsIgnoreCase(runtimeDialect)) {this.autoDialect = false;this.properties = properties;}//2.动态获取方言else if (StringUtil.isEmpty(dialect)) {autoDialect = true;this.properties = properties;}//3.指定方言else {autoDialect = false;this.delegate = instanceDialect(dialect, properties);}}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/2944.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

第一篇【传奇开心果系列】Python深度学习库技术点案例示例:深度解读深度学习在自动驾驶领域的应用

传奇开心果博文系列 系列博文目录Python深度学习库技术点案例示例系列 博文目录前言一、深度学习在自动驾驶方面的应用介绍二、目标检测和识别示例代码三、路况感知示例代码四、行为预测示例代码五、路径规划示例代码六、自动驾驶控制示例代码七、感知融合示例代码八、高精度地…

【数据结构】串(String)

文章目录 基本概念顺序存储结构比较当前串与串s的大小取子串插入删除其他构造函数拷贝构造函数扩大数组空间。重载重载重载重载[]重载>>重载<< 链式存储结构链式存储结构链块存储结构 模式匹配朴素的模式匹配算法(BF算法)KMP算法字符串的前缀、后缀和部分匹配值nex…

Android 10.0 Launcher3替换桌面app图标后大小和其他app图标不一样的问题解决方案

1.前言 在10.0的系统ROM产品定制化开发中,在关于launcher3的产品定制化开发中,在有些时候需要对一些第三方的app图标做 替换或者是做一些动态图标的替换,发现在替换以后图标大小和其他app的图标大小不一样,所以就需要看是具体哪里 对app的图标做了缩放功能,接下来就需要去…

【网页在线小游戏源码】

网页在线小游戏源码 效果图部分源码领取源码下期更新预报 效果图 部分源码 index.html <!DOCTYPE html> <html> <head> <meta http-equiv"Content-Type" content"text/html; charsetUTF-8"> <meta id"viewport" na…

WEB逆向—X-Bogus逆向分析(纯算+补环境)

声明 本文章中所有内容仅供学习交流&#xff0c;抓包内容、敏感网址、数据接口均已做脱敏处理&#xff0c;严禁用于商业用途和非法用途&#xff0c;否则由此产生的一切后果均与作者无关&#xff0c;若有侵权&#xff0c;请联系我立即删除&#xff01; 前言 此平台 本人 仅限…

分类预测 | Matlab实现CNN-BiLSTM-SAM-Attention卷积双向长短期记忆神经网络融合空间注意力机制的数据分类预测

分类预测 | Matlab实现CNN-BiLSTM-SAM-Attention卷积双向长短期记忆神经网络融合空间注意力机制的数据分类预测 目录 分类预测 | Matlab实现CNN-BiLSTM-SAM-Attention卷积双向长短期记忆神经网络融合空间注意力机制的数据分类预测分类效果基本描述程序设计参考资料 分类效果 基…

Spring Boot 如何进行多环境配置

在SpringBoot中管理不同环境的配置确实是一个常见且重要的实践。通过使用不同的配置文件&#xff0c;你可以轻松地在开发、测试和生产环境之间切换&#xff0c;而无需手动更改配置信息。这不仅提高了开发效率&#xff0c;还减少了因配置错误导致的潜在问题。 要实现这一点&…

深入探究音视频开源库WebRTC中NetEQ音频抗网络延时与抗丢包的实现机制

目录 1、引言 2、WebRTC简介 3、什么是NetEQ&#xff1f; 4、NetEQ技术详解 4.1、NetEQ概述 4.2、抖动消除技术 4.3、丢包补偿技术 4.4、NetEQ概要设计 4.5、NetEQ的命令机制 4.6、NetEQ的播放机制 4.7、MCU的控制机制 4.8、DSP的算法处理 4.9、DSP算法的模拟测试…

分布式与一致性协议之CAP(二)

CAP CAP不可能三角 CAP不可能三角是指对于一个分布式系统而言&#xff0c;一致性、可用性、分区容错性指标不可兼得&#xff0c;只能从中选择两个&#xff0c; 如图所示。CAP不可能三角最初是埃里克布鲁尔(Eric Brewer)基于自己的工程实践提出的一个猜想&#xff0c;后被塞斯吉…

论文辅助笔记:LLM-MOB代码解读

论文笔记 Where Would I Go Next? Large Language Models as Human Mobility Predictor-CSDN博客 1 主函数 1.1 导入库 import os import pickle import time import ast import logging from datetime import datetime import pandas as pd from openai import OpenAIclie…

【003_音频开发_基础篇_Linux进程通信(20种你了解几种?)】

003_音频开发_基础篇_Linux进程通信&#xff08;20种你了解几种&#xff1f;) 文章目录 003_音频开发_基础篇_Linux进程通信&#xff08;20种你了解几种&#xff1f;)创作背景Linux 进程通信类型fork() 函数fork() 输出 2 次fork() 输出 8 次fork() 返回值fork() 创建子进程 方…

Diffusion Model原理剖析

目录 前言1. DDPM演算法初览2. 图像生成模型共同目标3. VAE: Lower bound of l o g P ( x ) logP(x) logP(x)4. Diffusion Model背后的数学原理5. 为什么需要Sample?6. Diffusion Model的应用7. Diffusion Model成功的关键总结参考 前言 接着上篇文章 图像生成模型浅析&#…

1-k8s集群安装报错CGROUPS_CPU: missing

加入集群报错 [rootiZuf65r8i4e90z40vlh8mgZ ~]# kubeadm join 172.19.35.202:6443 --token 9edy1q.209zfq0387qtiv5x --discovery-token-ca-cert-hash sha256:24e0953896046aa8ce573ec7faf6609b87250883a7691fcad70a0faa81978c3b --control-plane --cri-socket "unix://…

Three.js入门学习笔记

学习资料&#xff1a; 【Three.js】Three.js快速上手教程_three.module.js-CSDN博客 2024年了&#xff0c;是该学学Three.js了_three.js 2024-CSDN博客 一、three.js简介 three.js是JavaScript编写的WebGL第三方库。 three.js&#xff0c;webGL&#xff0c;openGL三者的关…

【Linux高性能服务器编程】两种高性能并发模式剖析——领导者/追随者模式

hello &#xff01;大家好呀&#xff01; 欢迎大家来到我的Linux高性能服务器编程系列之两种高性能并发模式介绍&#xff0c;在这篇文章中&#xff0c;你将会学习到高效的创建自己的高性能服务器&#xff0c;并且我会给出源码进行剖析&#xff0c;以及手绘UML图来帮助大家来理解…

SpringBoot自动配置底层源码分析

文章目录 1. 什么是SpringBoot的自动装配&#xff1f;2. SpringBoot自动装配的底层原理 1. 什么是SpringBoot的自动装配&#xff1f; Spring Boot的自动配置是一种机制&#xff0c;它使得开发者能够快速地开始构建Spring应用&#xff0c;而不需要手动编写大量的样板代码。Spri…

代码随想录第34天: 贪心part03

力扣 1005.K次取反后最大化的数组和 class Solution {public int largestSumAfterKNegations(int[] nums, int k) {// 将基本类型的int数组转换成IntStream&#xff0c;以便进行流操作。nums Arrays.stream(nums)// 将IntStream中的int元素转换&#xff08;装箱&#xff09;为…

FRPC+PHP+MYSQL+APACHE2=个人网站

应用背景有公网需求,但是又不想去买又贵又低配置的服务器,然后方案就应运而生 frp/README_zh.md at dev fatedier/frp (github.com) 在这里, FRPC作为内网穿透服务, PHPMYSQLAPACHE2,作为网站搭建,具体细节不细讲, 但是在我的/var/www/html下面 linaroHinlink:/var/www/h…

17_c/c++开源库 easylogging日志库

1.简介与安装 简介: EasyLogging的主要特点包括&#xff1a; 简单易用&#xff1a;EasyLogging的API设计简洁明了&#xff0c;使用起来非常方便。开发者只需包含头文件并初始化库&#xff0c;即可开始记录日志。 高效性&#xff1a;EasyLogging采用异步日志记录方式&#xff…

CSS3新增特性(二)

四、2D 转换 • 属性名&#xff1a;transform &#xff08;可用于制作2D转换&#xff0c;也可用于制作3D转转换&#xff1b;2D转换是平面上的转换&#xff0c;3D转换是在三维立体空间的转换&#xff09; • 作用&#xff1a;对元素进行水平或垂直方向的移动、缩放、旋转、拉长…