先来看看这个spring的配置文件的配置:
<!-- 事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 配置事务的传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="get*" propagation="REQUIRED" read-only="true" />
<tx:method name="del*" propagation="REQUIRED" />
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<!-- 配置事务拦截器拦截哪些类的哪些方法,一般设置成拦截Service -->
<aop:config>
<aop:pointcut expression="execution(* com.xy.service.*.*(..))"
id="allDaoMethod" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="allDaoMethod" />
</aop:config>
表示com.xy.service包下的所有方法为为事务管理。
execution(* com.aptech.jb.epet.dao.hibimpl.*.*(..))
这样写应该就可以了 这是com.aptech.jb.epet.dao.hibimpl 包下所有的类的所有方法。。
第一个*代表所有的返回值类型
第二个*代表所有的类
第三个*代表类所有方法 最后一个..代表所有的参数。
下面给出一些常见切入点表达式的例子:
-
任意公共方法的执行:
execution(public * *(..))
-
任何一个以“set”开始的方法的执行:
execution(* set*(..))
-
AccountService
接口的任意方法的执行:execution(* com.xyz.service.AccountService.*(..))
-
定义在service包里的任意方法的执行:
execution(* com.xyz.service.*.*(..))
-
定义在service包或者子包里的任意类的任意方法的执行:
execution(* com.xyz.service..*.*(..))
相关推荐
基于XML的声明式AspectJ <bean id="myAspect" class="com.itheima.aspectj.xml.MyAspect" /> <aop:config> <aop:aspect id="aspect" ref="myAspect"> <aop:pointcut expression="execution(* com.itheima.jdk.*.*(....
<aop:pointcut expression="execution(* com.spring.service..*(..))" id="pointCut"/>声明一个切入点,注意execution表达式的写法 <aop:before method="before" pointcut-ref="pointCut"/> aop前置通知 ...
<!--配置连接池--> <bean id="dataSource" class=... <aop:pointcut id="pointcut" expression="execution(* com.itheima.service.impl.*.*(..))"/> <aop:advisor advice-ref="advice" pointcut-ref=
expression="execution(* x.y.service.*Service.*(..))" /> id="noTxServiceOperation" expression="execution(* x.y.service.ddl.DefaultDdlManager.*(..))" /> pointcut-ref="defaultServiceOperation" ...
写法一: @Before("execution(* com.bjpowernode.springboot07.javabean.Man.eat(..))") 一、AOP开发 1.1 概述 1.2使用方法 1.3创建项目并添加maven依赖 1.4 创建Javabean测试类 1.5 创建切面 1.6 测试类 1.7 测试...
expression="execution(* *..servi1ce*..*(..))"/> <aop:advisor pointcut-ref="serviceOperation" advice-ref="txAdvice"/> <!-- 通知配置 --> <tx:advice id="txAdvice" transaction-manager="myJtaManager...
Missing Hive Execution Jar: /hive/hive1.2.1/lib/hive-exec-*.jar
<aop:pointcut id="allManagerMethodPdm" expression="execution(* com.ccc.pdm..*.*(..))"/> <aop:advisor pointcut-ref="allManagerMethodPdm" advice-ref="txAdvicePdm"/> </aop:config> <!-- ibatis...
<aop:pointcut expression="execution(* com.direct.service.*.*(..))" id="transactionPointCut"/> <aop:advisor advice-ref="transactionAdvice" pointcut-ref="transactionPointCut"/> spring和struts2的整合 ...
LabVIEW.2009.v9.0.Desktop.Execution.Trace.Toolkit.ISO-TBE-keygen
<aop:pointcut expression="execution(* com.org.service.*.*(..))" id="bussinessService" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="bussinessService"/> <!-- 配置那个类那个方法用到事务...
Hardware_Accelerated_Execution_Manager.rar.rar
<?xml version="1.0" encoding="UTF-8"?> <!-- - Application context ... <aop:advisor pointcut="execution(* com.longxian.drp.manager.*.*(..))" advice-ref="txAdvice"/> </aop:config> </beans>
<property name="mapperLocations" value="classpath:mapping/*.xml"> <!-- DAO接口所在包名,Spring会自动查找其下的类 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> ...
<aop:pointcut expression="execution(public * com.org.service.*.*(..))" id="bussinessService" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="bussinessService" /> <!-- 配置那个类那个方法...
//"${catalina.base}/lib/*.jar","${catalina.home}/lib","${catalina.home}/lib/*.jar" //读取common.loader String value = CatalinaProperties.getProperty(name + ".loader"); if ((value == null) || ...
<aop:pointcut id="allServiceMethod" expression="execution(* com.cstp.service.*.*(..))"/> <aop:advisor pointcut-ref="allServiceMethod" advice-ref="txAdvice"/> <!-- 新闻类型 --> <bean id=...
SQL Server Execution Times: CPU time = 0 ms, elapsed time = 0 ms. SQL Server Execution Times: CPU time = 0 ms, elapsed time = 0 ms. SQL Server Execution Times: CPU time = 0 ms, elapsed time = ...
<aop:pointcut expression="execution(public * com.org.core.service.*.*(..))" id="bussinessService" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="bussinessService" /> <!-- 配置那个类...
软件项目管理-Execution-V200.ppt