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

网站开场flash怎么做的p2p免费网站建设

网站开场flash怎么做的,p2p免费网站建设,成都抖音推广公司,wordpress mysuc cms目录 Spring事务操作-事务引入 1.模拟异常 2.测试异常 3.没有使用spring框架的时候异常该如何处理 4.使用spring框架的时候异常该如何处理 5.在spring 进行声明式事务管理#xff0c;底层使用AOP 6.spring 事务管理API 7.事务操作#xff08;注解声明式事务管理…目录 Spring事务操作-事务引入 1.模拟异常 2.测试异常 3.没有使用spring框架的时候异常该如何处理 4.使用spring框架的时候异常该如何处理 5.在spring 进行声明式事务管理底层使用AOP 6.spring 事务管理API 7.事务操作注解声明式事务管理 1在spring的配置文件中配置事务管理器 2在spring 配置文件中开启事务注解 3在service 类上面或者service类里面的方法上面 添加事务注解 4Transactional这个注解添加到类上面也可以添加到方法上面 5测试 上一章的代码如果正常执行   不会出现问题 如果在代码执行过程中出现异常会出现问题 因此我们引入事务这个概念 Spring事务操作-事务引入 1.模拟异常 在业务逻辑层中的service层中模拟异常 package org.example.spring.service;import org.example.spring.dao.UserDao; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;Service public class UserService {Autowiredprivate UserDao userDao;// 转账方法调用public void accountMoney(){//lucy少100userDao.reduceMoney();//模拟异常int i10/0;//mary多100userDao.addMoney();}}2.测试异常 原来的数据库值 后来的数据库值 分析lucy的钱少了mary 的钱却没有增加 3.没有使用spring框架的时候异常该如何处理 package org.example.spring.service;import org.example.spring.dao.UserDao; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;Service public class UserService {Autowiredprivate UserDao userDao;// 转账方法调用public void accountMoney(){ // 1.开启事务try{ // 2.进行业务操作//lucy少100userDao.reduceMoney();//模拟异常int i10/0;//mary多100userDao.addMoney();// 3.没有发生异常提交事务}catch(Exception e){ // 4.如果发生了异常从第3跳到第4进行事务回滚}}}4.使用spring框架的时候异常该如何处理 1事务添加到javaEE三层结构里面的service层 业务逻辑层 2在spring 进行事务管理操作有两种方式 【第一种】编程式事务管理相当于3. 里面的操作 【第二种】声明式事务管理常用 1.基于注解方式常用 2.基于xml 配置方式 5.在spring 进行声明式事务管理底层使用AOP 6.spring 事务管理API 1spring 提供了一个接口代表是事务管理器事务操作都封装在里面 这个接口针对不同的框架提供不同的实现类例如以下的红框就是整合JDBC框架的子类 实现类 7.事务操作注解声明式事务管理 1在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:aophttp://www.springframework.org/schema/aopxsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd!-- 开启组件扫描--context:component-scan base-packageorg.example/context:component-scan !--数据库连接池--bean iddataSource classcom.alibaba.druid.pool.DruidDataSource destroy-methodcloseproperty nameurl valuejdbc:mysql://localhost:3306/user_db?useSSLfalseamp;useUnicodetrueamp;characterEncodingUTF-8/property nameusername valueroot/property namepassword valuesise/property namedriverClassName valuecom.mysql.jdbc.Driver//bean!-- 创建jdbcTemplate对象--bean idjdbcTemplate classorg.springframework.jdbc.core.JdbcTemplate !--需要注入数据源信息--property namedataSource refdataSource/property/bean!-- 创建事务管理器-- bean iddataSourceTransactionManager classorg.springframework.jdbc.datasource.DataSourceTransactionManagerproperty namedataSource refdataSource/property /bean /beans 2在spring 配置文件中开启事务注解 引入名称空间tx 开启事务注解 3在service 类上面或者service类里面的方法上面 添加事务注解 4Transactional这个注解添加到类上面也可以添加到方法上面 如果把这个注解添加类上面这个类里面所有的方法都添加事务 如果把这个注解添加方法上面仅仅为这个方法添加事务 package org.example.spring.service;import org.example.spring.dao.UserDao; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional;Service Transactional public class UserService {Autowiredprivate UserDao userDao;// 转账方法调用public void accountMoney(){ //1.开启事务 // try{ // 2.进行业务操作//lucy少100userDao.reduceMoney();//模拟异常int i10/0;//mary多100userDao.addMoney();// 3.没有发生异常提交事务// }catch(Exception e){ // 4.如果发生了异常从第3跳到第4进行事务回滚// }}}5测试 原来数据 后来数据不变 只是在控制台提示报错信息
http://www.pierceye.com/news/899749/

相关文章:

  • 廊坊网站建设哪家权威网址导航大全排名
  • 北京建站公司哪个好05网电子书
  • 权威网站设计wordpress通知站点360搜索
  • 做靓号网站凡客小程序
  • 创建网站开发公司公司做个网站
  • 做网站的工具+论坛html怎么自己做网站
  • 土木在线seo网站快速整站优化技术
  • 创造力网站设计建设有限公司网站
  • 如何做网站好看做h5小程序的网站
  • 济宁网站建设价格做网站公司深
  • ae成品免费下载网站申请一个app多少钱
  • 我想自己在网站上发文章 怎样做免费观看高清正能量直播下载
  • 做网站万网长春建站模板展示
  • 广州专业建网站公司福州网站制作
  • 西安烽盈网站建设郑州营销网站托管
  • 诸几建设银行网站怎么维护好网站
  • 深圳市国外网站建设简单html5网页设计
  • 网站制作公司西南城乡建设部网站首页
  • 网站名和域名能一样吗企业网站建设硬件
  • 德州做网站公司怎么开网店淘宝
  • 苏州做网站优化的电商定制开发
  • 广西庆海建设发展有限公司网站昆山有做网站的公司吗
  • 前端课程网站wordpress 微博登陆
  • asp怎么做网站适配开发公司安置房项目工程推进大会
  • 学做网站可以赚钱吗怎么批量修改wordpress文章内容
  • 写作网站vir上海博大园林建设发展有限公司网站
  • wordpress video gallery网站代码优化怎么做
  • 厦门网站设计品牌企业互联网门户网站建设
  • 做名片模板网站中文响应式网站
  • 用tornado做网站石家庄 外贸网站建设公司