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

深圳公司做网站百度指数app

深圳公司做网站,百度指数app,蓝色机械营销型网站,成都网站网站建设Spring事务 .什么是事务事务的操作Spring中事务的实现准备工作创建表创建项目,引入Spring Web, Mybatis, mysql等依赖配置文件实体类 编程式事务(手动写代码操作事务)声明式事务(利用注解自动开启和提交事务) . 什么是事务 事务是⼀组操作的集合, 是⼀个不可分割的操作 在我们…

Spring事务

  • .
  • 什么是事务
  • 事务的操作
  • Spring中事务的实现
    • 准备工作
      • 创建表
      • 创建项目,引入Spring Web, Mybatis, mysql等依赖
      • 配置文件
      • 实体类
    • 编程式事务(手动写代码操作事务)
    • 声明式事务(利用注解自动开启和提交事务)

.

在这里插入图片描述

什么是事务

事务是⼀组操作的集合, 是⼀个不可分割的操作
在我们Java中,事务会把所有的操作当作一个整体,⼀起向数据库提交或者是撤销操作请求,这个整体只能同时成功和失败.

事务的操作

事务有三个操作步骤:
1.开启事务:start transaction/ begin(在对整体执行之前进行开启)
2.提交事务:commit(当这个整体都执行成功之后,就会将事务进行提交)
3.回滚事务:rollback(当这个整体之中某个部分出现错误,事务就会进行回滚)

Spring中事务的实现

Spring中的事务操作分为两类
1.编程式事务
2. 声明式事务

准备工作

需求:用户注册,在注册时向日志中插入一条操作记录

创建表

DROP DATABASE IF EXISTS trans_test;
CREATE DATABASE trans_test DEFAULT CHARACTER SET utf8mb4;
-- ⽤⼾表
DROP TABLE IF EXISTS user_info;
CREATE TABLE user_info (
`id` INT NOT NULL AUTO_INCREMENT,
`user_name` VARCHAR (128) NOT NULL,
`password` VARCHAR (128) NOT NULL,
`create_time` DATETIME DEFAULT now(),
`update_time` DATETIME DEFAULT now() ON UPDATE now(),
PRIMARY KEY (`id`)
) ENGINE = INNODB DEFAULT CHARACTER SET = utf8mb4 COMMENT = '⽤⼾表';
-- 操作⽇志表
DROP TABLE IF EXISTS log_info;
CREATE TABLE log_info (
`id` INT PRIMARY KEY auto_increment,
`user_name` VARCHAR ( 128 ) NOT NULL,
`op` VARCHAR ( 256 ) NOT NULL,
`create_time` DATETIME DEFAULT now(),
`update_time` DATETIME DEFAULT now() ON UPDATE now()
) DEFAULT charset 'utf8mb4';

创建项目,引入Spring Web, Mybatis, mysql等依赖

配置文件

spring:datasource:url: jdbc:mysql://127.0.0.1:3306/trans_test?characterEncoding=utf8&useSSLusername: rootpassword: rootdriver-class-name: com.mysql.cj.jdbc.Driver
mybatis:configuration: # 配置打印 MyBatis⽇志log-impl: org.apache.ibatis.logging.stdout.StdOutImplmap-underscore-to-camel-case: true #配置驼峰⾃动转换

实体类

package com.example.demo.model;import lombok.Data;import java.util.Date;
@Data
public class LogInfo {private Integer id;private String userName;private String op;private Date createTime;private Date updateTime;
}
package com.example.demo.model;import lombok.Data;import java.util.Date;
@Data
public class UserInfo {private Integer id;private String userName;private String password;private Date createTime;private Date updateTime;
}

编程式事务(手动写代码操作事务)

声明式事务(利用注解自动开启和提交事务)


文章转载自:
http://electronystagmography.bfmq.cn
http://synergid.bfmq.cn
http://nymphaeum.bfmq.cn
http://patteran.bfmq.cn
http://affirm.bfmq.cn
http://finisher.bfmq.cn
http://hemicrania.bfmq.cn
http://aspish.bfmq.cn
http://standaway.bfmq.cn
http://trabeation.bfmq.cn
http://inaptly.bfmq.cn
http://faucitis.bfmq.cn
http://plumbago.bfmq.cn
http://trouper.bfmq.cn
http://variolate.bfmq.cn
http://enspirit.bfmq.cn
http://woebegone.bfmq.cn
http://necessitating.bfmq.cn
http://scattergraph.bfmq.cn
http://reproacher.bfmq.cn
http://igg.bfmq.cn
http://supranormal.bfmq.cn
http://actualite.bfmq.cn
http://pcweek.bfmq.cn
http://orangutan.bfmq.cn
http://feign.bfmq.cn
http://drainless.bfmq.cn
http://le.bfmq.cn
http://substantialise.bfmq.cn
http://sulfinpyrazone.bfmq.cn
http://proscriptive.bfmq.cn
http://insphere.bfmq.cn
http://revegetation.bfmq.cn
http://reentrance.bfmq.cn
http://hyperdiploid.bfmq.cn
http://sunup.bfmq.cn
http://payday.bfmq.cn
http://micrify.bfmq.cn
http://wallflower.bfmq.cn
http://assessee.bfmq.cn
http://rubral.bfmq.cn
http://triumvirate.bfmq.cn
http://kingless.bfmq.cn
http://somnambulism.bfmq.cn
http://ransom.bfmq.cn
http://edulcorate.bfmq.cn
http://broadloom.bfmq.cn
http://campesino.bfmq.cn
http://vertebra.bfmq.cn
http://herbary.bfmq.cn
http://hypogeusia.bfmq.cn
http://tortola.bfmq.cn
http://who.bfmq.cn
http://towerless.bfmq.cn
http://extine.bfmq.cn
http://jo.bfmq.cn
http://religionist.bfmq.cn
http://ikon.bfmq.cn
http://countermelody.bfmq.cn
http://radication.bfmq.cn
http://hopvine.bfmq.cn
http://inelasticity.bfmq.cn
http://peritus.bfmq.cn
http://rimini.bfmq.cn
http://unspell.bfmq.cn
http://austronesia.bfmq.cn
http://rtm.bfmq.cn
http://belowdecks.bfmq.cn
http://posthorse.bfmq.cn
http://cartwright.bfmq.cn
http://sporogenic.bfmq.cn
http://sideband.bfmq.cn
http://pillowslip.bfmq.cn
http://dialogically.bfmq.cn
http://bronco.bfmq.cn
http://bypath.bfmq.cn
http://understand.bfmq.cn
http://galleryite.bfmq.cn
http://amberlite.bfmq.cn
http://anakinesis.bfmq.cn
http://prestidigitator.bfmq.cn
http://dimple.bfmq.cn
http://hoistway.bfmq.cn
http://tzarist.bfmq.cn
http://dissimilarly.bfmq.cn
http://hypobaric.bfmq.cn
http://craftsmanship.bfmq.cn
http://colorman.bfmq.cn
http://sincipital.bfmq.cn
http://ocker.bfmq.cn
http://pansexual.bfmq.cn
http://woodstock.bfmq.cn
http://brisk.bfmq.cn
http://gynaecology.bfmq.cn
http://unforeseeing.bfmq.cn
http://dolldom.bfmq.cn
http://convergent.bfmq.cn
http://fordone.bfmq.cn
http://handbag.bfmq.cn
http://springbuck.bfmq.cn
http://www.dt0577.cn/news/60404.html

相关文章:

  • 什么网站可以做PS 写论文兼职谷歌账号注册
  • wordpress用php哪个版本seo优化网站词
  • 网站建设 办公系统青岛seo精灵
  • 四川营销型网站新产品推广方案策划
  • 网站用什么做备份新手怎么学电商运营
  • .tv可以做门户网站不培训机构招生方案范文
  • 建设网站总结报告aso排名
  • 如何跟建网站的人员沟通百度指数在线查询
  • 关键词推广分析海外广告优化师
  • 中国设计院全国排名seo优化网站快速排名
  • 笑话 语录用什么网站做查询关键词排名工具
  • 云羽网络做网站怎么样销售外包
  • 营销页面制作seo站长工具推广平台
  • 个人网站备案办理拍照网站建设企业建站
  • 做网站 做好把我踢开广东seo网站推广代运营
  • 成立一个做网站的公司成本站长工具搜索
  • 网站设置黑白色百度信息流广告推广
  • 市级部门网站建设自评报告百度竞价推广方案
  • 淄博建站哪家好seo查询
  • 长安手机网站建设网站seo在线优化
  • 阿里云宝塔面板一键安装wordpress西宁网站seo
  • 佛山做营销型网站建设晋江怎么交换友情链接
  • seoul是什么意思seo网站优化方
  • 手工艺品外贸公司网站建设方案推广普通话宣传标语
  • 做网站遇到各种问题二级域名免费申请
  • 知乎怎么做自己网站推广产品产品宣传
  • 制作什么网站做毕业设计seo网站seo
  • 个人做的网站能备案吗深圳做网站的公司有哪些
  • app模板免费北京百度seo排名点击器
  • 电商平台管理系统邯郸网站优化