@Componet声明当前组件
@AspectJ可以把类声明为在这里插入代码片在这里插入代码片切面类
定义切入点和额外功能
//定义切入点
@Pointcut("execution(* com.qianfeng..UserServiceImpl.*(..))")
public void log04(){}
//定义额外功能
@Before("log04()")
public void mylog(JoinPoint jp){
String methodName = jp.getSignature().getName();
System.out.println(methodName+" 于 "+new Date()+" 被访问啦");
}
web集成
ContextLoaderLisener:使工厂的启动时刻足够靠前
在web.xml中添加启动工厂
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
声明spring配置文件weizhi
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext_annotation.xml</param-value>
</context-param>
</