springboot连接mysql8,transactional结果不能回滚

SpringBoot事务管理之@Transactional的使用 概述 什么是事务?举个简单的例子,假如小明现在打算从自己的银行账户转账5W元至小花的银行账户,这涉及到了两个操作,第一个是从小明的账户内提走5W,第二个是将这5W块汇入小花的账户,如果第一步操作正常而第二步操作出了问题,那么我们要保证第一步操作能被撤销掉,否则小明就要天台见了。。。 那么事务管理就是解决这一类问题的有效手段,它保证一组操作要么全部完成(提交Commit),要么有任何一环出现差错就要... 阅读详情

下午测试了几条数据,符合的能插入进入,不符合出异常后没有回滚

查询了很多配置,本质上是不用检查的,因为默认是支持事务的

所以应该先查mysql的表的配置,默认是MyISAM,那就不支持回滚了

所以要么直接用工具设置表为InnoDB;

要么写语句

ALTER TABLE `database名`.`表名`
ENGINE = InnoDB;

很多东西,不记下来就忘记了。

SpringBoot系列:事务管理器Transactional 以上是字节二面的一些问题,面完之后其实挺后悔的,没有提前把各个知识点都复习到位。现在重新好好复习手上的。 阅读详情

相关推荐

Spring boot+Atomikos+JTA+Hibernate+mybatis+MySQL实现分布式事务+多数据源

springboot+Atomikos+jpa+mysql的JTA分布式事务实现,本案例涉及到2个数据库,预期结果,在同一个事务中,两个库的状态一致

spring mysql 事务回滚失败_技术贴 | Spring事务不回滚问题排查

原标题:技术贴 | Spring事务不回滚问题排查 本技术贴是我司技术小哥在开发新项目中遇到的问题时的分析及思考,学霸的人生学无止境。01问题描述在新项目的开发中遇到一个奇葩的问题:方法添加了事务后数据库不回滚,而且不是每一个方法都不回滚,是有的方法回滚,有的不回滚。02问题背景新项目使用SpringBoot2.0+Mybatis框架,启用事务的方式是在类的方法上使用@Transactional注...

weixin_30198949的博客 364

在Windows11上安装ubuntu版linux系统并实现桌面图形化(WSL)

在Windows11上安装ubuntu版linux系统并实现桌面图形化(WSL),xfce桌面美化、安装google-chrome

NiKoJJ‘s Blog 1万+

SpringBoot事务不回滚,不生效

常见坑点1:遇到检测异常时,事务默认不回滚。 SQLException 原因分析:因为Spring的默认的事务规则是遇到运行异常(RuntimeException及其子类)和程序错误(Error)才会进行事务回滚,显然SQLException并不属于这个范围。如果想针对检测异常进行事务回滚,可以在@Transactional 注解里使用 rollbackFor 属性明确指定异常。例如下面这样,就可以正常回滚 @Transactional(rollbackFor = Exception.class) 常见

qq_38693803的博客 1961

STM32:TTL串口调试

TTL只需要两个线就可以完成两个设备之间的双向通信,一个发送电平的I/O称之为TX,与另一个设备的接收I/O口RX相互连接。两设备之间还需要连接地线(GND),这样两设备就有相同的0V参考电势。

superSmart_Dong的博客 5640

优快云独家 | 全网首发 | 《目标检测蓝皮书》目录

10篇文章从目标检测小白变大神

Coding... 3万+

面试突击:SpringBoot 事务不回滚?怎么解决?

本文我们介绍了 5 种事务不自动回滚的场景和相应的解决方案,开发者应该根据自己的实际情况,选择合适自己解决方案进行处理。

Huangjiazhen711的博客 2250

【用unity实现100个游戏之10】复刻经典俄罗斯方块游戏(附项目源码)

当今游戏产业中,经典游戏的复刻一直是一项受欢迎且具有挑战性的任务。俄罗斯方块是一个深入人心、令人上瘾的经典游戏,在过去几十年里一直享有广泛的流行度。其简单而富有策略性的玩法吸引了无数玩家的关注。因此,我决定利用Unity引擎来复刻这款经典游戏,以让更多的人重新体验其中的乐趣。通过使用Unity引擎,我能够利用其强大的工具和功能,从头开始构建一个与原版俄罗斯方块游戏相似的游戏。

向宇的博客,专注php/web全栈 unity游戏开发,欢迎大家评论纠错 2798

spring声明式事务 @Transactional 不回滚的多种情况以及解决方案

在实际开发中我们经常用到 spring声明式事务 @Transactional 注解,但是偶尔也会遇到事务不回滚的情况,本文将介绍几种常见的情况,已经如何正确使用!

ratel的博客 1万+

3.1 快速启动Flink集群

在本实战中,我们将快速启动Apache Flink 1.13.0集群,并在Hadoop集群环境中提交作业。首先,我们会在本地下载Flink安装包并上传至云主机,解压并配置环境变量。接着,我们将启动Flink集群,通过访问Web UI进行监控管理。然后,我们会配置集群,将Flink分发到从节点,并在集群上提交作业。最后,我们将通过命令行提交作业,并在Web UI上查看任务节点的输出结果。这个过程涵盖了Flink集群的部署、配置和作业提交,为大数据处理提供了一个完整的实战经验。

howard2005的专栏 727

华为OD机试真题 新系统 - WIFI设备网络规划 (Java/Py/C/C++/Js/Go)

本文整理华为 OD 机试新系统机考真题库,涵盖高频考点精析与完整题目内容,提供 C 语言、Java、C++、Python、Go、JavaScript 多语言源码实现,搭配详细解题思路讲解,并支持在线 OJ 刷题练习,助力高效备考华为 OD 机试新系统。

算法大师! 2017

使用Spring boot的@Transactional进行事务管理

在 Spring Boot 中,是用于声明式事务管理的关键注解。它基于 Spring 的 AOP(面向切面编程)实现,可以简化数据库事务的管理。

TracyCoder的博客 3400

(功能安全六)硬件FMEDA计算

FMEDA(故障模式、影响与诊断分析)是功能安全验证的核心方法,通过量化分析硬件故障模式及其影响,计算SPFM、LFM、PMHF等关键指标。分析过程包含六大步骤:计算元器件失效率、识别故障模式、评估安全机制诊断覆盖率、分类计算各类失效率、量化指标计算及设计优化。输入需要系统架构图、硬件故障模式清单等资料,输出安全指标达标情况及改进建议,确保设计满足ASIL等级要求。该方法通过系统化的故障分类和量化评估,为硬件安全设计提供科学依据。

Dayongger的博客 1453

基于MySQL ,SpringBoot,分布式事务Transactional不能回滚的处理

本人现在学习基于JTA的分布式事务的处理,当有多个数据源的时候,为了保持业务的原子性,需要进行分布式事务处理,但是在检查完各项java配置都没问题后发现抛出Exception时候事务无法回滚,摸索了大半天,终于找到了问题,问题点就是MYSQL数据库表的默认类型没有改成InnoDB类型,它默认的是MyISAM,由于MyISAM不支持事务处理等高级处理,而InnoDB类型支持。改为InnoDB就支持事

u011267841的博客 2795

HQChart实战教程19 - PC端分时图定制tooltip

HQChart实战教程19 - PC端分时图定制tooltip序效果步骤1. 创建一个外部tooltip的div2. 注册标题绘制事件3. 标题绘制回调函数格式说明eventdataobjtooltip显示函数HQChart代码地址 序 hqchart分时图是不带tooltip, 如果我们需要在PC端页面显示tooltip,我们可以通过注册绘制标题事件,来自己做一个div显示数据。 参考教程HQChart实战教程7-自定义显示手势点击K线显示信息 效果 步骤 1. 创建一个外部tooltip的div 在外

小银 2447

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

浅谈Mysql数据库事务操作 用mybatis操作mysql事务 再在Springboot中使用Spring事务控制mysql事务回滚

现在是有三张表 第一张表为 t_sentence 表 列有 id content create_time from hot other1 other2 other2 第二张表为 t_tags 表 列有 id name from hot other1 other2 other3 create_time 第三张表为t_sentence表和t_tags 表的中间表 t_sentence_tag 列有 id sentence_id tag_id create_time 现在我要往第一张表里插入数据 现有数据

多多的博客 920

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

SpringBoot 异常回滚 事务的使用___Springboot @Transactional 事务不回滚

Springboot中事务的使用: 1、启动类加上@EnableTransactionManagement注解,开启事务支持(其实默认是开启的)。 2、在使用事务的public(只有public支持事务)方法(或者类-相当于该类的所有public方法都使用)加上@Transactional注解。 在实际使用中一般是在service中使用@Transactional,那么对于controller->service流程中: 如果controller未开启事务,service中开始了事务,service成功

qq_43842093的博客 1092

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

springboot的事务Transactional

Spring @Transactional原理及使用 springboot事务处理之Transactional(第2集) 1.SpringBoot开启事务后, 默认只对runTimeException执行回滚(如1除以0:1/0),或者Error; 对checkException不执行回滚(要显示声明的异常) 要对所有的异常都回滚,需要声明 Transactional(rollbackFor = Throwable.class)或者 Transactional(rollbackFor = Exceptio

nikyae的博客 692

Transactional注解无效,不支持回滚问题(1)

目前在学习SpringBoot,在使用 @Transactional 后,出错无法回滚 一开始是以为没捕捉到异常,于是写成 @Transactional(rollbackFor = Exception.class) 重新跑起来后,还是不能回滚(即还是有数据插入到库)。 检查代码也是与学习视频中的代码一致。   百度了解到: SpringBoot2.0中,Hibernate创建Mysq...

zenghz123的博客 495

在springboot中关于@Transactional事务注解不能回滚的原因

@Override @Transactional(readOnly = false,rollbackFor=Exception.class,propagation=Propagation.REQUIRED) public ResultBean&lt;String&gt; test(GoodsInfo goodsInfo) { try { GoodsInfo goodsInfo1 ...

请叫我小高同学 3197

Springboot @Transactional 事务不回滚

一、异常捕获的原因 这里Exception异常,他又分为运行时异常RuntimeException和非运行时异常 可查的异常(checked exceptions):Exception下除了RuntimeException外的异常 不可查的异常(unchecked exceptions):RuntimeException及其子类和错误(Error) 异常checked例外也回...

b078109的专栏 775

Spring boot 事务Transactional

开启事务只需要加上注解@Transactional即可 // 默认情况下数据库的事务作用范围是在JapRepository 的crud上 // save 一旦执行成功,就会进行提交 // 开启事务后遇到RunTimeException 以及子类异常会进行事务回滚 // 也可以自定义异常回滚级别 //@Transactional(rollbackFor = Exceptio...

weixin_30284355的博客 114

spring事务Transactional 中使用mysql truncate清空表对事务的影响

数据库版本为mysql8 springboot 2.5.6。 论坛里有别的博客说的truncate 后的sql无法提交的情况,在我使用的版本没有出现,可能他用的是比较老的版本。 public class TestTeacherController extends BaseController { @Resource private JdbcTemplate jdbcTemplate; @ApiOperation("删除数据") @PostMapping("delete")

qq_27037397的博客 1740

SpringBoot 系列教程之声明式事务 Transactional

当我们希望一组操作,要么都成功,要么都失败时,往往会考虑利用事务来实现这一点;之前介绍的 db 操作,主要在于单表的 CURD,本文将介绍声明式事务的使用姿势。

程序员高级码农的博客 1180

spring boot 事务 Transactional 笔记

最近发现事务不会回滚,查了原因总结一下原因: 1、@Transactional 没注解在public方法上 2、抛出的异常不是RuntimeException类异常,而@Transactional上没有注明rollbackFor哪一类异常。 解决方法可以是@Transactional( rollbackFor = Exception.class) 3、数据库存储引擎不支持回滚 以mysql为例,数据库引擎是MyISAM不回滚。把引擎改为InnoDB会回滚。 -- 查看库的存储引擎 show e.

xjj1314的专栏 211

springBoot事务

springBoot事务

打怪升级 775
上一篇: IntelliJ IDEA 配置多个jdk版本
下一篇: JAXBException解决办法
andyhas
博客等级 码龄12年 3粉丝 17原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值