这里写目录标题
spring aspect
因为xml配置aop太过繁琐,所以aopalliance 中出现了一种AspectJ技术。
基本流程:
1)通过注解配置切点
2)自动生产代理对象
怎么使用aspect技术
第1步:创建AppConfig.java
package com.jr.aspectJ;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
@Configuration //标示为配置类 相当于xml文件
//扫描指定包下包含@Component注解的类,将这个类加入spring bean工程
@ComponentScan(value= {
"com.jr.aspectJ","com.jr.dao.impl"})
@EnableAspectJAutoProxy//启动aspectJ注解aop
public class AppConfig {
}
第2步:创建@Aspect 切面类
package com.jr.aspectJ;
import java.util.Arrays