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

网站建设的几个阶段网页设计用什么软件做

网站建设的几个阶段,网页设计用什么软件做,python培训费用大概多少,备案网站大全文章目录 前言一、事务及其参数含义1.事务的四个特性2.事务的传播行为#xff08;propagation#xff09;3.事务隔离性4.事务的隔离级别#xff08;ioslation#xff09;5.timeout#xff08;超时#xff09;6.readOnly#xff08;是否只读#xff09;7.rollbackForpropagation3.事务隔离性4.事务的隔离级别ioslation5.timeout超时6.readOnly是否只读7.rollbackFor回滚8.noRollbackFor不回滚 二、事务管理1.事务管理的两种形式2.注解实现声明式事务管理3.xml实现声明式事务管理4.完全注解开发 总结 前言 事务是数据库操作最基本单位要么都成功要么都失败。 一、事务及其参数含义 1.事务的四个特性 原子性一致性隔离性持久性。 2.事务的传播行为propagation Spring定义了7种传播行为 传播属性描述REQUIRED如果有事务在运行当前的方法就在这个事务内运行否则就启动一个新的事务并在自己的事务内运行REQUIRED_NEW当前的方法必须启动新事务并在它自己的事务内运行如果有事务正在运行应该将它挂起SUPPORTS如果有事务在运行当前的方法就在这个事务内运行否则它可以不运行在事务中NOT_SUPPORTED当前方法不应该运行在事务中如果有运行的事务将它挂起MANDATORY当前的方法不应该运行在事务中如果有运行的事务就抛出异常NESTED如果有事务在运行当前的方法就应该在这个事务的嵌套事务内运行否则就启动一个新的事务并在它自己的事务内运行 这里只图解介绍一个其他类推 3.事务隔离性 脏读一个未提交事务读取到另一个未提交事务的数据 例事务A读取到事务B修改后的数据但是读取后事务B回滚了此时A读取的是修改后的数据但是修改撤销了。不可重复读一个未提交的事务读取到另一个提交事务修改数据 例事务A和事务B读取同一个数据但是事务B在读取后进行修改然后提交提交后事务A又读取这个数据此时读取的是修改后的跟上次读取的不一样。幻读虚读一个未提交的事务读取到另一个提交事务添加数据 4.事务的隔离级别ioslation 5.timeout超时 事务在一定时间内进行提交如果不提交会进行回滚默认值是-1设置时间以秒为单位进行计算。 6.readOnly是否只读 读查询写增删改 默认值是false表示可以增删改查设置true后只能查询。 7.rollbackFor回滚 设置出现哪些异常进行事务回滚。 8.noRollbackFor不回滚 设置出现哪些异常不进行事务回滚。 二、事务管理 Spring事务管理提供了一个接口叫做事务管理器这个接口针对不同的框架提供不同的实现类。 1.事务管理的两种形式 编程式事务管理 例 try{//开启事务//进行业务操作userDao.reduceMoney();//模拟异常int i10/0;userDao.addMoney();//没出现异常事务提交}catch (Exception e){//异常事务回滚}声明式事务管理AOP原理 例 Service Transactional(timeout -1,propagation Propagation.REQUIRED,isolation Isolation.READ_COMMITTED) public class UserService{Autowiredprivate UserDao userDao;public void accountMoney(){userDao.reduceMoney();int i 1 / 0;userDao.addMoney();} }2.注解实现声明式事务管理 就是上述声明式管理的例子这里补充一下全部代码 userDao package com.dragon.shiwu.dao;public interface UserDao {public void addMoney();public void reduceMoney(); } userDaoImpl package com.dragon.shiwu.dao;import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Repository;Repository public class UserDaoImpl implements UserDao{Autowiredprivate JdbcTemplate jdbcTemplate;Overridepublic void addMoney() {String sqlupdate t_account set moneymoney ? where username ?;jdbcTemplate.update(sql,100,mary);}Overridepublic void reduceMoney() {String sqlupdate t_account set moneymoney-? where username?;jdbcTemplate.update(sql,100,lucy);} } userService package com.dragon.shiwu.service;import com.dragon.shiwu.dao.UserDao; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional;Service Transactional(timeout -1,propagation Propagation.REQUIRED,isolation Isolation.READ_COMMITTED) public class UserService{Autowiredprivate UserDao userDao;public void accountMoney(){userDao.reduceMoney();int i 1 / 0;userDao.addMoney();} } Spring配置文件注意这里引入了tx命名空间和 ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:contexthttp://www.springframework.org/schema/contextxmlns:txhttp://www.springframework.org/schema/txxsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsdcontext:property-placeholder locationclasspath:jdbc.properties/bean iddataSource classcom.alibaba.druid.pool.DruidDataSourceproperty namedriverClassName value${pro.driverClass}/propertyproperty nameurl value${pro.url}/propertyproperty nameusername value${pro.username}/propertyproperty namepassword value${pro.password}/property/bean !--创建JdbcTemplate对象--bean idjdbcTemplate classorg.springframework.jdbc.core.JdbcTemplate!--注入数据库连接池--property namedataSource refdataSource/property/beancontext:component-scan base-packagecom.dragon.shiwu/context:component-scan !--创建事务管理器--bean idtransactionManager classorg.springframework.jdbc.datasource.DataSourceTransactionManagerproperty namedataSource refdataSource/property/bean!-- 开启事务注解--tx:annotation-driven transaction-managertransactionManager/tx:annotation-driven /beans 运行前 运行后 3.xml实现声明式事务管理 Spring配置文件 ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:contexthttp://www.springframework.org/schema/contextxmlns:txhttp://www.springframework.org/schema/txxmlns:aophttp://www.springframework.org/schema/aopxsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsdcontext:property-placeholder locationclasspath:jdbc.properties/bean iddataSource classcom.alibaba.druid.pool.DruidDataSourceproperty namedriverClassName value${pro.driverClass}/propertyproperty nameurl value${pro.url}/propertyproperty nameusername value${pro.username}/propertyproperty namepassword value${pro.password}/property/beanbean idjdbcTemplate classorg.springframework.jdbc.core.JdbcTemplateproperty namedataSource refdataSource/property/bean !-- 开启组件扫描--context:component-scan base-packagecom.dragon.shiwu/context:component-scan!--配置事务通知--tx:advice idtxadvicetx:attributes!--配置事务参数--tx:method nameaccountMoney propagationREQUIRED//tx:attributes/tx:advice!-- 配置切入点和切面--aop:config !-- 配置切入点--aop:pointcut idpt expressionexecution(* com.dragon.shiwu.service.UserService.*(..))/ !-- 配置切面--aop:advisor advice-reftxadvice pointcut-refpt/aop:advisor/aop:config /beans4.完全注解开发 TxConfig类 package com.dragon.shiwu.config;import com.alibaba.druid.pool.DruidDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement;import javax.sql.DataSource;Configuration//配置类 ComponentScan(basePackages com.dragon.shiwu)//组件扫描 EnableTransactionManagement//开启事务 public class TxConfig {//创建数据库连接池Beanpublic DruidDataSource getDruidDataSource(){DruidDataSource druidDataSource new DruidDataSource();druidDataSource.setDriverClassName(com.mysql.cj.jdbc.Driver);druidDataSource.setUrl(jdbc:mysql://localhost:3306/user_db);druidDataSource.setUsername(root);druidDataSource.setPassword(root);return druidDataSource;}//创建JdbcTemplate对象Beanpublic JdbcTemplate getJdbcTemplate(DataSource dataSource){JdbcTemplate jdbcTemplate new JdbcTemplate();jdbcTemplate.setDataSource(dataSource);return jdbcTemplate;}//创建事务管理器Beanpublic DataSourceTransactionManager getDataSourceTransactionManager(DataSource dataSource){DataSourceTransactionManager transactionManager new DataSourceTransactionManager();transactionManager.setDataSource(dataSource);return transactionManager;}} 测试类 package com.dragon.shiwu.test;import com.dragon.shiwu.config.TxConfig; import com.dragon.shiwu.service.UserService; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;public class test2 {public static void main(String[] args) {ApplicationContext contextnew AnnotationConfigApplicationContext(TxConfig.class);UserService userService context.getBean(userService,UserService.class);userService.accountMoney();} } 总结 以上就是Spring事务管理的讲解。
http://www.w-s-a.com/news/618667/

相关文章:

  • 深圳技术支持 骏域网站建设wordpress 酒主题
  • 东莞网站建设+旅游网站改版数据来源表改怎么做
  • 手机端做的优秀的网站设计企业做网站大概多少钱
  • 优化网站使用体验手机网站解析域名
  • 网站制作 商务做网站的软件名字全拼
  • 阿里巴巴网官方网站温州网站建设设计
  • 传奇购买域名做网站国外网站设计 网址
  • 西安凤城二路网站建设seo网站是什么
  • 网站后台如何更换在线qq咨询代码在线种子资源网
  • 东莞网站优化制作免费中文wordpress主题下载
  • 东莞建筑设计院排名网络优化论文
  • 做牙工作网站郑州前端开发培训机构
  • 温州专业建站网站制作的管理
  • 公司网站开发策划书有没有专门做教程的网站
  • 江苏省工程建设信息网站一天赚1000块钱的游戏
  • 制作响应式网站报价品牌建设整体体系包括什么
  • 网站推广策划报告目前做win7系统最好的网站
  • 东莞网站建设咨询公江西网站建设平台
  • 什么是网站功能源码下载站
  • 石家庄制作网站的公司双柏县住房和城乡建设局网站
  • 影视vip网站建设教程ppt模板免费下载 素材红色
  • 内蒙古城乡建设部网站首页平台网站建设ppt
  • 集约化网站建设项目官方网站建设
  • 原创先锋 北京网站建设网站开发电脑内存要多少
  • 婚恋网站建设项目创业计划书网站建设 食品
  • 免费建网站代码查询做导员的网站
  • 做网站的软件电子可以看女人不易做网站
  • 学校响应式网站模板下载仙居住房和城乡建设规划局网站
  • 推广网站的方法有拍卖网站建设
  • 网站建设网站排名优化中国网站服务器哪个好