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

spring cloud seata集成

目录

一、seata使用场景 

二、seata组成

三、seata服务端搭建

四、客户端使用seata

4.1 客户端增加undo_log表

4.2 客户端增加seata相关配置

4.3 客户端使用注解

五、测试


一、seata使用场景 

微服务中,一个业务涉及到多个微服务系统,每个微服务系统连接不同的数据库,要求数据一致性时使用。如下订单操作,调用下订单方法后,需要增加订单记录、减少产品库存;订单记录和产品库存 调用不同的微服务  数据存储在不同的数据库中;

调用下订单方法时,订单服务或库存服务任何一个出现问题,此方法执行失败,数据库记录需回滚。

理论支持:cap、base;

理论依据:二阶段提交法(准备、执行);三阶段提交法(询问、准备、执行);消息最终一致性;最大努力通知法;

解决方案:tcc(try-confirm-cancel)、sega、X/A等。

二、seata组成

seata是spring cloud生态中的分布式事务解决方案,包括seata服务端和客户端;

seata服务端是独立部署的;(seata担当事务协调器角色)

seata客户端,即每个微服务增加相关依赖和配置,使用@GlobalTransactional(rollbackFor = Exception.class)注解即可;

三、seata服务端搭建

1. 下载seata服务端包;

本文使用的是seata1.7.0版本的包。

2. 修改seata配置文件 application.yml,使用nacos注册seata服务,管理seata服务配置;

路径seata>conf,application.yml

#  Copyright 1999-2019 Seata.io Group.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.server:port: 7091spring:application:name: seata-serverlogging:config: classpath:logback-spring.xmlfile:path: ${user.home}/logs/seataextend:logstash-appender:destination: 127.0.0.1:4560kafka-appender:bootstrap-servers: 127.0.0.1:9092topic: logback_to_logstash
console:user:username: seatapassword: seataseata:config:# support: nacos 、 consul 、 apollo 、 zk  、 etcd3type: nacosnacos:server-addr: 127.0.0.1:8948namespace:group: SEATA_GROUPusername: nacospassword: context-path:##if use MSE Nacos with auth, mutex with username/password attribute#access-key:#secret-key:data-id: seataServer.propertiesregistry:# support: nacos 、 eureka 、 redis 、 zk  、 consul 、 etcd3 、 sofatype: nacosnacos:application: seata-serverserver-addr: 127.0.0.1:8948group: SEATA_GROUPnamespace:cluster: defaultusername: nacospassword: context-path:##if use MSE Nacos with auth, mutex with username/password attribute#access-key:#secret-key:security:secretKey: tokenValidityInMilliseconds: 1800000ignore:urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.jpeg,/**/*.ico,/api/v1/auth/login

在nacos中增加seata配置:

seataServer.properties配置文件:

#For details about configuration items, see https://seata.io/zh-cn/docs/user/configurations.html
#Transport configuration, for client and server
transport.type=TCP
transport.server=NIO
transport.heartbeat=true
transport.enableTmClientBatchSendRequest=false
transport.enableRmClientBatchSendRequest=true
transport.enableTcServerBatchSendResponse=false
transport.rpcRmRequestTimeout=30000
transport.rpcTmRequestTimeout=30000
transport.rpcTcRequestTimeout=30000
transport.threadFactory.bossThreadPrefix=NettyBoss
transport.threadFactory.workerThreadPrefix=NettyServerNIOWorker
transport.threadFactory.serverExecutorThreadPrefix=NettyServerBizHandler
transport.threadFactory.shareBossWorker=false
transport.threadFactory.clientSelectorThreadPrefix=NettyClientSelector
transport.threadFactory.clientSelectorThreadSize=1
transport.threadFactory.clientWorkerThreadPrefix=NettyClientWorkerThread
transport.threadFactory.bossThreadSize=1
transport.threadFactory.workerThreadSize=default
transport.shutdown.wait=3
transport.serialization=seata
transport.compressor=none#Transaction routing rules configuration, only for the client
service.vgroupMapping.default_tx_group=default
#If you use a registry, you can ignore it
service.default.grouplist=127.0.0.1:8091
service.enableDegrade=false
service.disableGlobalTransaction=false#Transaction rule configuration, only for the client
client.rm.asyncCommitBufferLimit=10000
client.rm.lock.retryInterval=10
client.rm.lock.retryTimes=30
client.rm.lock.retryPolicyBranchRollbackOnConflict=true
client.rm.reportRetryCount=5
client.rm.tableMetaCheckEnable=true
client.rm.tableMetaCheckerInterval=60000
client.rm.sqlParserType=druid
client.rm.reportSuccessEnable=false
client.rm.sagaBranchRegisterEnable=false
client.rm.sagaJsonParser=fastjson
client.rm.tccActionInterceptorOrder=-2147482648
client.tm.commitRetryCount=5
client.tm.rollbackRetryCount=5
client.tm.defaultGlobalTransactionTimeout=60000
client.tm.degradeCheck=false
client.tm.degradeCheckAllowTimes=10
client.tm.degradeCheckPeriod=2000
client.tm.interceptorOrder=-2147482648
client.undo.dataValidation=true
client.undo.logSerialization=jackson
client.undo.onlyCareUpdateColumns=true
server.undo.logSaveDays=7
server.undo.logDeletePeriod=86400000
client.undo.logTable=undo_log
client.undo.compress.enable=true
client.undo.compress.type=zip
client.undo.compress.threshold=64k
#For TCC transaction mode
tcc.fence.logTableName=tcc_fence_log
tcc.fence.cleanPeriod=1h#Log rule configuration, for client and server
log.exceptionRate=100#Transaction storage configuration, only for the server. The file, db, and redis configuration values are optional.
store.mode=db
store.lock.mode=db
store.session.mode=db
#Used for password encryption
store.publicKey=#These configurations are required if the `store mode` is `db`. If `store.mode,store.lock.mode,store.session.mode` are not equal to `db`, you can remove the configuration block.
store.db.datasource=druid
store.db.dbType=mysql
store.db.driverClassName=com.mysql.cj.jdbc.Driver
store.db.url=jdbc:mysql://127.0.0.1:3306/seata?useUnicode=true&rewriteBatchedStatements=true
store.db.user=root
store.db.password=
store.db.minConn=5
store.db.maxConn=30
store.db.globalTable=global_table
store.db.branchTable=branch_table
store.db.distributedLockTable=distributed_lock
store.db.queryLimit=100
store.db.lockTable=lock_table
store.db.maxWait=5000#Transaction rule configuration, only for the server
server.recovery.committingRetryPeriod=1000
server.recovery.asynCommittingRetryPeriod=1000
server.recovery.rollbackingRetryPeriod=1000
server.recovery.timeoutRetryPeriod=1000
server.maxCommitRetryTimeout=-1
server.maxRollbackRetryTimeout=-1
server.rollbackRetryTimeoutUnlockEnable=false
server.distributedLockExpireTime=10000
server.xaerNotaRetryTimeout=60000
server.session.branchAsyncQueueSize=5000
server.session.enableBranchAsyncRemove=false
server.enableParallelRequestHandle=false#Metrics configuration, only for the server
metrics.enabled=false
metrics.registryType=compact
metrics.exporterList=prometheus
metrics.exporterPrometheusPort=9898

3. 创建seata服务所需数据库表;

在seata script目录下找到sql脚本

执行sql语句建表:

-- -------------------------------- The script used when storeMode is 'db' --------------------------------
-- the table to store GlobalSession data
CREATE TABLE IF NOT EXISTS `global_table`
(`xid`                       VARCHAR(128) NOT NULL,`transaction_id`            BIGINT,`status`                    TINYINT      NOT NULL,`application_id`            VARCHAR(32),`transaction_service_group` VARCHAR(32),`transaction_name`          VARCHAR(128),`timeout`                   INT,`begin_time`                BIGINT,`application_data`          VARCHAR(2000),`gmt_create`                DATETIME,`gmt_modified`              DATETIME,PRIMARY KEY (`xid`),KEY `idx_status_gmt_modified` (`status` , `gmt_modified`),KEY `idx_transaction_id` (`transaction_id`)
) ENGINE = InnoDBDEFAULT CHARSET = utf8mb4;-- the table to store BranchSession data
CREATE TABLE IF NOT EXISTS `branch_table`
(`branch_id`         BIGINT       NOT NULL,`xid`               VARCHAR(128) NOT NULL,`transaction_id`    BIGINT,`resource_group_id` VARCHAR(32),`resource_id`       VARCHAR(256),`branch_type`       VARCHAR(8),`status`            TINYINT,`client_id`         VARCHAR(64),`application_data`  VARCHAR(2000),`gmt_create`        DATETIME(6),`gmt_modified`      DATETIME(6),PRIMARY KEY (`branch_id`),KEY `idx_xid` (`xid`)
) ENGINE = InnoDBDEFAULT CHARSET = utf8mb4;-- the table to store lock data
CREATE TABLE IF NOT EXISTS `lock_table`
(`row_key`        VARCHAR(128) NOT NULL,`xid`            VARCHAR(128),`transaction_id` BIGINT,`branch_id`      BIGINT       NOT NULL,`resource_id`    VARCHAR(256),`table_name`     VARCHAR(32),`pk`             VARCHAR(36),`status`         TINYINT      NOT NULL DEFAULT '0' COMMENT '0:locked ,1:rollbacking',`gmt_create`     DATETIME,`gmt_modified`   DATETIME,PRIMARY KEY (`row_key`),KEY `idx_status` (`status`),KEY `idx_branch_id` (`branch_id`),KEY `idx_xid` (`xid`)
) ENGINE = InnoDBDEFAULT CHARSET = utf8mb4;CREATE TABLE IF NOT EXISTS `distributed_lock`
(`lock_key`       CHAR(20) NOT NULL,`lock_value`     VARCHAR(20) NOT NULL,`expire`         BIGINT,primary key (`lock_key`)
) ENGINE = InnoDBDEFAULT CHARSET = utf8mb4;INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('AsyncCommitting', ' ', 0);
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('RetryCommitting', ' ', 0);
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('RetryRollbacking', ' ', 0);
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('TxTimeoutCheck', ' ', 0);

四、客户端使用seata

示例由三个服务组成,seataDemoWeb、demo-order、demo-product;

其中seataDemoWeb服务提供rest接口test,此接口调用demo-order和demo-product服务,增加订单记录,修改库存。

4.1 客户端增加undo_log表

demo-order和demo-product,两个服务对应的数据库均需增加undo_log表;

建表语句:

CREATE TABLE `undo_log` (`id` bigint(20) NOT NULL AUTO_INCREMENT,`branch_id` bigint(20) NOT NULL,`xid` varchar(100) NOT NULL,`context` varchar(128) NOT NULL,`rollback_info` longblob NOT NULL,`log_status` int(11) NOT NULL,`log_created` datetime NOT NULL,`log_modified` datetime NOT NULL,`ext` varchar(100) DEFAULT NULL,PRIMARY KEY (`id`),UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

4.2 客户端增加seata相关配置

seataDemoWeb、demo-order和demo-product在application.properties中增加seata配置

seata.enabled=true
seata.application-id=${spring.application.name}
seata.tx-service-group=seata-tx-group
seata.service.vgroup-mapping.seata-tx-group=default
seata.registry.type=nacos
seata.registry.nacos.server-addr=127.0.0.1:8948
seata.registry.nacos.username=nacos
seata.registry.nacos.password=
seata.registry.nacos.namespace=public
seata.registry.nacos.group=SEATA_GROUP
seata.registry.nacos.application=seata-server

pom增加seata依赖,完整pom.xml

<?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>2.2.10.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>hj.example</groupId><artifactId>productDemo</artifactId><version>1.0.0</version><packaging>jar</packaging><properties><lombok.version>1.18.24</lombok.version></properties><dependencies><dependency><groupId>hj.example</groupId><artifactId>demoCommon</artifactId><version>1.0.0</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.12</version></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>${lombok.version}</version></dependency><!-- nacos --><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId><version>2.2.5.RELEASE</version></dependency><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId><version>2.2.5.RELEASE</version></dependency><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-dubbo</artifactId><version>2.2.5.RELEASE</version></dependency><!-- seata --><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-seata</artifactId><version>2.2.5.RELEASE</version><exclusions><exclusion><groupId>io.seata</groupId><artifactId>seata-spring-boot-starter</artifactId></exclusion></exclusions></dependency><dependency><groupId>io.seata</groupId><artifactId>seata-spring-boot-starter</artifactId><version>1.7.0</version></dependency></dependencies>
</project>

 

4.3 客户端使用注解

在seataDemoWeb服务中,增加@GlobalTransaction注解

package hj.example.seatademoweb.controller;import com.baomidou.mybatisplus.extension.service.IService;
import hj.example.democommon.entity.DemoOrder;
import hj.example.democommon.entity.DemoProduct;
import hj.example.democommon.entity.StateEnum;
import hj.example.democommon.services.DemoOrderService;
import hj.example.democommon.services.DemoProductService;
import io.seata.spring.annotation.GlobalTransactional;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;import java.util.Random;/*** @Description: TODO* @Author: * @Date: 2023/8/29**/
@RestController
public class TestController {@DubboReference(interfaceName = "demoOrderService")private DemoOrderService demoOrderService;@DubboReference(interfaceName = "demoProductService")private DemoProductService demoProductService;@RequestMapping("/test")@GlobalTransactional(rollbackFor = Exception.class)public ResponseEntity<Object> test() {DemoOrder demoOrder =new DemoOrder();demoOrder.setAccountId("1");demoOrder.setState(StateEnum.NEW.name());demoOrderService.save(demoOrder);DemoProduct demoProduct = new DemoProduct();demoProduct.setNum(Math.random()*10000);demoProductService.save(demoProduct);return new ResponseEntity<>("success", HttpStatus.OK);}
}

五、测试

修改4.3中的代码,debug查看回滚

DemoProduct demoProduct = new DemoProduct();
demoProduct.setNum(1/0);
demoProductService.save(demoProduct);

相关文章:

spring cloud seata集成

目录 一、seata使用场景 二、seata组成 三、seata服务端搭建 四、客户端使用seata 4.1 客户端增加undo_log表 4.2 客户端增加seata相关配置 4.3 客户端使用注解 五、测试 一、seata使用场景 微服务中&#xff0c;一个业务涉及到多个微服务系统&#xff0c;每个微服务…...

HTTP 常⻅的状态码有哪些,以及适⽤场景

⼀、HTTP状态码 HT T P 状态码&#xff08; HT T P S t a t u s Co d e &#xff09;是⽤来表示⽹⻚服务器超⽂本传输协议响应状态的 3 位数字代 码。它由 RFC 2 6 1 6 规范定义&#xff0c;并得到 RFC 2 5 1 8 、 RFC 2 8 1 7 、 RFC 2 2 9 5 、 RFC 2 7 7 4 与 RFC 4 9 1 8…...

后端给前端传参数忽略空属性

JsonInclude JsonInclude注解用于指定在对象序列化为JSON字符串时&#xff0c;哪些属性应该被包含进去&#xff0c;哪些属性应该被忽略掉。 JsonInclude注解有以下几个常用选项&#xff1a; JsonInclude(JsonInclude.Include.NON_NULL)&#xff1a;表示只有属性值不为null的属…...

SPSS教程:如何绘制带误差的折线图

SPSS教程&#xff1a;如何绘制带误差的折线图 1、问题与数据 研究者想研究45-65岁健康男性中&#xff0c;静坐时长和血胆固醇水平的关系&#xff0c;故招募100名研究对象询问其每天静坐时长&#xff08;time&#xff09;&#xff0c;并检测其血液中胆固醇水平&#xff08;cho…...

积分商城小程序如何精细化运营

随着移动互联网的发展&#xff0c;积分商城小程序成为了企业私域营销的重要组成部分。通过积分商城&#xff0c;企业可以激励用户参与、增加用户粘性&#xff0c;实现更好的用户互动和忠诚度提升。然而&#xff0c;要取得成功&#xff0c;积分商城小程序需要经过精细化的运营。…...

企业网络日志管理:EventLog Analyzer的卓越之处

企业网络日志管理对于维护网络安全、监控系统性能和合规性非常重要。随着网络规模和复杂性的增加&#xff0c;管理日志变得越来越具有挑战性。幸运的是&#xff0c;有一些优秀的工具可以帮助企业实现高效的日志管理。其中一款值得一提的工具是EventLog Analyzer。 一、EventLo…...

Python算法——滑动窗口问题

关于滑动窗口的概念&#xff0c;请自行到网上搜索相关资料&#xff0c;了解清楚再看本博客。 一、子组数最大平均数 LeetCode 第643题&#xff1a;https://leetcode.cn/problems/maximum-average-subarray-i/ 给你一个由 n 个元素组成的整数数组 nums 和一个整数 k 。 请你…...

使用 MATLAB 和 Simulink 对雷达系统进行建模和仿真

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…...

Linux 中的 sysctl 命令及示例

介绍 Linux管理员使用该命令在运行时sysctl读取或修改内核参数。无需重新启动即可实时控制和修改网络、 I/O 操作和内存管理设置的选项对于高可用性系统至关重要。 了解如何使用该sysctl命令及其选项来动态调整系统性能。...

Mybatis批量更新数据及其优化

需求场景&#xff1a;定时任务中&#xff0c;从其他平台同步数据&#xff0c;并更新当前平台数据库&#xff0c;表数据3W&#xff0c;分批更新某个字段&#xff0c;耗时巨大&#xff0c;约30min&#xff0c;尝试性能优化。 批量更新的几种常见方式&#xff1a; 1.foreach 循环…...

包含文心一言在内的首批国产大模型 全面开放

8月31起&#xff0c;国内 11 家通过《生成式人工智能服务管理暂行办法》备案的 AI 大模型产品将陆续上线&#xff0c;面向全社会开放。北京 5 家大模型产品分别是百度的 “文心一言”、抖音的 “云雀”、百川智能的 “百川大模型”、清华系 AI 公司智谱华章旗下的 “智谱清言”…...

Linux运维工程师面试题集锦

Linux运维工程师面试题集锦 一、Linux基础问题1.1 Linux的几个常用命令有哪些?1.2 Linux如何查看当前系统版本?1.3 Linux系统的文件权限有哪些?1.4 Linux如何修改文件权限?1.5 如何在Linux系统中查看文件内容?1.6 Linux的发行版本有哪些?1.7 Linux的文件系统是什么样子的…...

深度学习——感受野以及与图像修复的问题

在CNN中&#xff0c;决定某一层输出结果中一个元素所对应的输入层的区域大小被称作感受野&#xff08;receptive field&#xff09;&#xff0c;指的是神经网络中一个神经元可以感知到的区域&#xff0c;在CNN中&#xff0c;即 上某个元素的计算受输入图像上影响的区域&#xf…...

微服务容错 Resilience4j 接口服务-容错原理

微服务容错 Resilience4j 容错原理 4.1 微服务容错简介 在⾼并发访问下&#xff0c;⽐如天猫双11&#xff0c;流量持续不断的涌⼊&#xff0c;服务之间的相互调⽤频率突然增加&#xff0c;引发系统负载过⾼&#xff0c;这时系统所依赖的服务的稳定性对系统的影响⾮常⼤&#…...

OceanBase 4.x改装:另一种全链路追踪的尝试

本文作者&#xff1a;夏克 OceanBase 社区文档贡献者&#xff0c;曾多次参与 OceanBase 技术征文比赛&#xff0c;获得优秀名次。从事金融行业核心系统设计开发工作多年&#xff0c;服务于某交易所子公司&#xff0c;现阶段负责国产数据库调研。 本文为 OceanBase 第七期技术征…...

springCloudAlibaba详解

一、概述 1、简介 Spring Cloud Alibaba&#xff0c;它是由一些阿里巴巴的开源组件和云产品组成的。这个项目的目的是为了给Java开发者带来使用 Spring Boot 和 Spring Cloud 的更多便利。 Spring Cloud Alibaba 致力于 提供微服务开发的一站式解决方案。该项目包含开发分布…...

python通过docker打包执行

背景 正常情况下,python脚本执行需要安装有python环境,那python环境虽然也可以通过移植的方法来安装,那总归是比较麻烦的,下面通过docker打包的方式来执行python脚本 1、安装python镜像 准备两个文件即可,dockerfile、requirements.txt两个文件的内容分别如下 同目录下…...

实现公网远程访问:Windows本地快速搭建SFTP文件服务器并配置端口映射

文章目录 1. 搭建SFTP服务器1.1 下载 freesshd服务器软件1.3 启动SFTP服务1.4 添加用户1.5 保存所有配置 2 安装SFTP客户端FileZilla测试2.1 配置一个本地SFTP站点2.2 内网连接测试成功 3 使用cpolar内网穿透3.1 创建SFTP隧道3.2 查看在线隧道列表 4. 使用SFTP客户端&#xff0…...

获取文件路径

String fName " D:\\C#_Source\\test\\uploadFile\\test.xlsx";// 方法一&#xff1a; File tempFile new File( fName.trim());String fileName tempFile.getName();System.out.println("fileName " fileName);// 方法二&#xff1a; String fName …...

如何自己实现一个丝滑的流程图绘制工具(八) 创建节点的文本标签

背景 节点的文本标签不希望是通过节点编辑实现&#xff0c;而是拿到节点名字渲染上去&#xff0c;包括连接线 createLabel(element, name, parent) {const modeling this.bpmnModeler.get(modeling)let labelCenter {}// 连接线上的标签if (element.type bpmn:SequenceFlo…...

Spring Boot多数据源配置运行报错:No operations allowed after connection closed连接异常的解决

上一篇文章我们讲了如何配置多数据源&#xff0c;但是配置在使用一段时间之后&#xff0c;查询数据库会发生报错&#xff1a;No operations allowed after connection closed。 一、问题原因&#xff1a; 经过排查发现是因为MySQL5.0以后针对超长时间DB连接做了一个处理&#…...

3、QT 的基础控件的使用

一、qFileDialog 文件窗体 Header: #include <QFileDialog> qmake: QT widgets Inherits: QDialog静态函数接口&#xff1a; void Widget::on_pushButton_clicked() {//获取单个文件的路径名QString filename QFileDialog :: getOpenFileName(this, tr("Open Fi…...

爬虫逆向实战(二十六)--某某学堂登录

一、数据接口分析 主页地址&#xff1a;某某学堂 1、抓包 通过抓包可以发现数据接口是Account/LoginPost 2、判断是否有加密参数 请求参数是否加密&#xff1f; 通过查看“载荷”模块可以发现pass是加密参数 请求头是否加密&#xff1f; 无响应是否加密&#xff1f; 无co…...

leetcode分类刷题:哈希表(Hash Table)(四、前缀和 处理连续子数组)

1、leetcode题目里对于元素加和的考察可谓是屡见不鲜&#xff0c;包括 简单的限定一个有效答案的两个或多个元素求和leetcode分类刷题&#xff1a;哈希表&#xff08;Hash Table&#xff09;&#xff08;一、简单的两数之和&#xff09;、在有序数组内对加和等于target的三元组…...

如何处理生产环境中的数据倾斜问题?

分析&回答 1、flink数据倾斜的表现&#xff1a; 任务节点频繁出现反压&#xff0c;增加并行度也不能解决问题 部分节点出现OOM异常&#xff0c;是因为大量的数据集中在某个节点上&#xff0c;导致该节点内存被爆&#xff0c;任务失败重启 2、数据倾斜产生的原因&#x…...

【WSN无线传感器网络恶意节点】使用 MATLAB 进行无线传感器网络部署研究

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…...

C# 实现浏览器控件设置

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System...

1130 - Host ‘17216.18083‘ is not allowed to connect to this MySQL server

mysql5.7 设置root远程登录 1、登录数据库 mysql -u root -p 2、设置root 用户允许远程登录,"your password" 是自己设置的密码&#xff1b; GRANT ALL PRIVILEGES ON *.* TO root% IDENTIFIED BY your password WITH GRANT OPTION; 3、刷新权限 FLUSH PRIVILEG…...

使用Spring的getBeansOfType实现接口多实现类的动态调用

使用Spring的getBeansOfType实现接口多实现类的动态调用 package com.xxl.job.admin.core.alarm;import com.xxl.job.admin.core.model.XxlJobInfo; import com.xxl.job.admin.core.model.XxlJobLog; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sp…...

(笔记三)opencv图像基础操作

强调&#xff1a;本文只为学习记录做笔记 详细可参考opencv官网 &#xff1a;https://docs.opencv.org/4.1.1/d0/d86/tutorial_py_image_arithmetics.html &#xff08;1&#xff09;将cv2的BGR模式改为RGB模式 #!/usr/bin/env python # -*- coding:utf-8 -*- ""&q…...