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

hbuilder可以做网站嘛seo数据

hbuilder可以做网站嘛,seo数据,代理网关,网站建设图书推荐场景模拟 参考基于注解的声明式事务 修改Spring的配置文件 将Spring配置文件中去掉tx:annotation-driven标签&#xff0c;并添加配置&#xff1a; <?xml version"1.0" encoding"UTF-8"?> <beans xmlns"http://www.springframework.org…

场景模拟

参考基于注解的声明式事务

修改Spring的配置文件

将Spring配置文件中去掉tx:annotation-driven标签,并添加配置:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://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-package="com.yogurt.spring6.xmltx"></context:component-scan><!--    数据源对象 引入外部属性文件,创建数据源对象--><context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder><bean id="druidDataSource" class="com.alibaba.druid.pool.DruidDataSource"><property name="url" value="${jdbc.url}"></property><property name="driverClassName" value="${jdbc.driver}"></property><property name="username" value="${jdbc.user}"></property><property name="password" value="${jdbc.password}"></property></bean><!--    JdbcTemplate对象--><bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"><property name="dataSource" ref="druidDataSource"></property></bean><!--    事务管理器--><bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="druidDataSource"></property></bean><!--    配置事务增强--><tx:advice id="txAdvice" transaction-manager="transactionManager"><tx:attributes><tx:method name="get*" read-only="true"/><tx:method name="update" read-only="false" propagation="REQUIRED"></tx:method><tx:method name="buy*" read-only="false" propagation="REQUIRED"></tx:method></tx:attributes></tx:advice><!--    配置切入点和通知使用的方法--><aop:config><aop:pointcut id="pt" expression="execution(* com.yogurt.spring6.xmltx.service.*.*(..))"/><aop:advisor advice-ref="txAdvice" pointcut-ref="pt"></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/721354/

相关文章:

  • 建设网站平台哪个好互联网营销外包推广
  • 工商注册企业名称查询广东seo网站推广代运营
  • 中纪委网站两学一做征文资源平台
  • java高端网站建设现在广告行业好做吗
  • wordpress 制作下载优化关键词怎么做
  • 宁波网站建设哪个公司好百度爱采购推广怎么入驻
  • 重庆市建设工程信息网特种作业企业网站seo多少钱
  • 域名备案做电影网站制作免费个人网站
  • 公司网络营销方案优化设计七年级上册数学答案
  • 网站建设策划方案网址搜索引擎
  • 艺术培训学校系统网站怎么做百度优化是什么
  • 自己的网站做飘窗百度推广账号登录入口
  • 国内好的网站建设国内外十大免费crm软件推荐
  • 淄博品质网站建设百度销售推广
  • 网站建设学习内容网站模板哪家好
  • 建立b2b网站成本微信营销平台系统
  • 学做衣服网 缤纷网站手机百度ai入口
  • 点餐系统网站建设画质优化app下载
  • 上海都有哪些企业公司seo网站seo
  • 进一步加强政府网站建设网站建设介绍ppt
  • 做网站的设计软件上海seo推广外包
  • 中国工程局人才招聘网福建seo推广方案
  • 深圳南山做网站的公司百度投诉中心
  • 辽宁建设工程信息网业绩认定武汉网站优化公司
  • 莱芜都市人才网上海网站seo公司
  • 广州做鞋的网站怎么让某个关键词排名上去
  • 温州平阳县网站建设兼职东莞网络推广哪家公司奿
  • 做单页网站价格微信朋友圈广告在哪里做
  • 濮阳家电网站建设一般开车用什么导航最好
  • html5 图片展示网站大作设计网站