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

网站的建设步骤上海的网站设计公司

网站的建设步骤,上海的网站设计公司,拒绝做网站的理由,沈阳seo整站优化场景模拟 参考基于注解的声明式事务 修改Spring的配置文件 将Spring配置文件中去掉tx:annotation-driven标签#xff0c;并添加配置#xff1a; ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org…场景模拟 参考基于注解的声明式事务 修改Spring的配置文件 将Spring配置文件中去掉tx:annotation-driven标签并添加配置 ?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/tx xmlns:aophttp://www.springframework.org/schema/aopxsi:schemaLocationhttp://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop.xsd!-- 开启组件扫描--context:component-scan base-packagecom.yogurt.spring6.xmltx/context:component-scan!-- 数据源对象 引入外部属性文件创建数据源对象--context:property-placeholder locationclasspath:jdbc.properties/context:property-placeholderbean iddruidDataSource classcom.alibaba.druid.pool.DruidDataSourceproperty nameurl value${jdbc.url}/propertyproperty namedriverClassName value${jdbc.driver}/propertyproperty nameusername value${jdbc.user}/propertyproperty namepassword value${jdbc.password}/property/bean!-- JdbcTemplate对象--bean idjdbcTemplate classorg.springframework.jdbc.core.JdbcTemplateproperty namedataSource refdruidDataSource/property/bean!-- 事务管理器--bean idtransactionManager classorg.springframework.jdbc.datasource.DataSourceTransactionManagerproperty namedataSource refdruidDataSource/property/bean!-- 配置事务增强--tx:advice idtxAdvice transaction-managertransactionManagertx:attributestx:method nameget* read-onlytrue/tx:method nameupdate read-onlyfalse propagationREQUIRED/tx:methodtx:method namebuy* read-onlyfalse propagationREQUIRED/tx:method/tx:attributes/tx:advice!-- 配置切入点和通知使用的方法--aop:configaop:pointcut idpt expressionexecution(* com.yogurt.spring6.xmltx.service.*.*(..))/aop:advisor advice-reftxAdvice pointcut-refpt/aop:advisor/aop:config /beans Controller Controller public class BookController {Autowiredprivate BookService bookService;/*** 买书的方法* param bookId* param userId*/public void buyBook(Integer bookId,Integer userId){//调用Service方法bookService.buyBook(bookId,userId);}}Service Service public class BookServiceImpl implements BookService {Autowiredprivate BookDao bookDao;/*** 买书的方法* param bookId* param userId*/Overridepublic void buyBook(Integer bookId, Integer userId) {//根据图书id查询图书价格Integer price bookDao.getBookPriceByBookId(bookId);//更新图书库存量 -1bookDao.updateStock(bookId);//更新用户表用户余额 -图书价格bookDao.updateUserBalance(userId,price);} }Dao Repository public class BookDaoImpl implements BookDao {Autowiredprivate JdbcTemplate jdbcTemplate;/*** 根据id查询图书价格* param bookId* return*/Overridepublic Integer getBookPriceByBookId(Integer bookId) {String sql select price from t_book where book_id ?;Integer price jdbcTemplate.queryForObject(sql, Integer.class, bookId);return price;}/*** 更新库存信息* param bookId*/Overridepublic void updateStock(Integer bookId) {String sql update t_book set stock stock -1 where book_id ?;jdbcTemplate.update(sql,bookId);}/*** 更新用户表用户余额 -图书价格* param userId* param price*/Overridepublic void updateUserBalance(Integer userId, Integer price) {String sql update t_user set balance balance - ? where user_id ?;jdbcTemplate.update(sql,price,userId);} } 测试 SpringJUnitConfig(locations classpath:beans-xml.xml) public class TestBookTx {Autowiredprivate BookController bookController;Testpublic void testBuyBook(){bookController.buyBook(1,1);}} 某些小细节
http://www.hkea.cn/news/14502862/

相关文章:

  • 东营企业网站制作创建一个平台需要什么
  • 做电商图的设计网站北京正邦设计公司官网
  • 网站开发需要多少费用静态网站提交表单怎么做
  • 做网站一般注册哪几类商标wordpress 按分类显示图片
  • 泉州市第一建设有限公司网站建设一个招聘网站
  • 做淘客的网站名称开通网站费可以做待摊费用吗
  • 吴忠门户网站建设繁体中文网站 怎么做
  • 上海都有哪些企业公司南阳seo长尾关键词
  • 网站建设与网页制作案例教程开通一个微信小程序
  • 网站制作如何做非微信官方网页自己做的网站
  • 做一个网站需要多少时间免费的导航页
  • 腾脉网建站网站手机优化
  • 在境外做网站网站全国工商企业信息查询官网
  • 广州 定制网站3000元网站编辑 图片批量
  • 做电商自建网站怎样长春网站建设模板制作
  • 网站群建设技术规范泰安建设网
  • wordpress升级文章编辑器南通网站搜索引擎优化
  • 民房做酒店出租网站appWordPress上不了
  • 长沙百度网站推广厂家创新的专业网站建设
  • 东莞物流网站建设上海室内设计公司排名前十强
  • wordpress同步微博评论百度seo入驻
  • 提高网站访问速度的建设方案仿70网站分类目录源码
  • 手机网站 建设广告设计从入门到精通
  • 网站美工要求管理网站 开发
  • 家纺行业英文网站模板电商网站设计公司皆选亿企邦
  • 如何做公司自己的网站首页域名转发网站
  • 岳阳网站建设公司网站开发石家庄
  • 梅林多丽工业区做网站枣阳网站建设_枣阳山水数码
  • 滨州改版网站建设服务wordpress 函数api文件路径
  • 江门网站推广公司wordpress 摄影工作室主题