代理增强
spring-aop
切入点
连接点
通知
切面
表达式
表达式
public void com.atguigu.service.HelloService.test(int,)
访问修饰符省略
void *
com.atguigu.service
*…
HelloService *
test *.
(int) *
全通配表达式
- ….()
配置方式
纯注解配置
@EnableAspectJAutoProxy
注解配置
aop:aspectj-autoproxy开启基于注解aop配置
@component
@aspect
通知类
@pointcut(“excution”)
public void pointcut(){}
@before(“pointcut”)
@afterreturning
@afterthrowing
@after
@around
public object around (pointcut point)
{
try{
//前置
poing.proceed();
//后置
}
catch(Throwable e){
//异常
throw new runtimeException();
}
finally{
//最终
}
}
XML配置
aop:config
<aop:pointcut id = “” pointcut = “excution(* ….*(…))”>
aop:aspect
<aop:before method = “” pointcut-ref = “”>
aop:after-returning
aop:after-throwing
aop:after
aop:around
aop:aspect
aop:config
基于spring-tx 配置事务
spring-jdbc
spring-tx
jdbc.datasource
事务管理器
抽象接口
PlatformTransactionManager
实现类
DataSourceTransactionManager
spring 自带数据源连接池
driverManagerDataSource