`
xmh517
  • 浏览: 64313 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Spring事务说明

阅读更多

最近有朋友问到spring中事务的配置,以下就是比较常见的配置

 

配置文件如下:

<?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:aop="http://www.springframework.org/schema/aop "
xmlns:tx="http://www.springframework.org/schema/tx "
xsi:schemaLocation="http://www.springframework.org/schema/beans
                     http://www.springframework.org/schema/beans/spring-beans.xsd
                     http://www.springframework.org/schema/tx
                     http://www.springframework.org/schema/tx/spring-tx.xsd
                     http://www.springframework.org/schema/aop
                     http://www.springframework.org/schema/aop/spring-aop.xsd ">

这些才是最关键的地方。。后面的配置不变。。。。


Spring使用 <tx:advice>和 <aop:config> 用来配置事务,具体如何配置你可以参考Spring文档。

我解释一下(* com.evan.crm.service.*.*(..))中几个通配符的含义:

第一个 * —— 通配 任意返回值类型
第二个 * —— 通配 包com.evan.crm.service下的任意class
第三个 * —— 通配 包com.evan.crm.service下的任意class的任意方法
第四个 .. —— 通配 方法可以有0个或多个参数

综上:包com.evan.crm.service下的任意class的具有任意返回值类型、任意数目参数和任意名称的方法

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics