让spring3.0可以使用aop注解的方法是导入两个jar包aspectjrt.jar aspectjweaver.jar
2013-12-23 13:41
796 查看
aspectjrt.jar
aspectjweaver.jar
package com.merit.memcache.aop;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
public class MemacheAdvice {
@Pointcut("execution(* com..*.add*(..))")
public void addAspect()
{
}
@Before(value="addAspect()")
public void before(JoinPoint point)
{
// User user =(User) point.getArgs()[0];
//
// System.out.println("anno-before"+user.getId());
}
@AfterReturning(pointcut="addAspect()")
public void back()
{
System.out.println("返回");
}
@Around("addAspect()")
public Object deal(ProceedingJoinPoint point)
{
System.out.println("around start");
Object object=null;
try {
object = point.proceed();
} catch (Throwable e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("around end");
return object;
}
}
aspectjweaver.jar
package com.merit.memcache.aop;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
public class MemacheAdvice {
@Pointcut("execution(* com..*.add*(..))")
public void addAspect()
{
}
@Before(value="addAspect()")
public void before(JoinPoint point)
{
// User user =(User) point.getArgs()[0];
//
// System.out.println("anno-before"+user.getId());
}
@AfterReturning(pointcut="addAspect()")
public void back()
{
System.out.println("返回");
}
@Around("addAspect()")
public Object deal(ProceedingJoinPoint point)
{
System.out.println("around start");
Object object=null;
try {
object = point.proceed();
} catch (Throwable e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("around end");
return object;
}
}
相关文章推荐
- spring3.0使用注解aop需要的jar包--及其流程
- Spring AOP aspectjweaver.jar包 4000
- 使用Spring3.0的AOP结合log4j实现接口方法执行时间记录
- [原创]java WEB学习笔记105:Spring学习---AOP介绍,相关概念,使用AOP,利用 方法签名 编写 AspectJ 切入点表达式
- Spring系列: 使用aop报错:nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$Refle
- Spring使用AspectJ注解和XML配置实现AOP
- Spring所依赖的AspectJ的jar包下载/Spring-aop注解jar包下载
- springmvc/spring使用注解的方法的时候完全可以忽略<!-- <context:annotation-config/> -->
- Spring中使用aop操作需要用到的aspectjweaver-1.8.7.jar包
- Spring AOP的使用 基于全注解AspectJ
- 使用Aspect注解启动web项目时出现NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorld
- Spring AOP 使用注解的方式实现用户日志的两种方法
- spring框架的学习(五)——Spring使用AspectJ进行AOP的开发:注解方式
- (转)Spring使用AspectJ进行AOP的开发:注解方式
- 使用Spring注解AOP(基于自定义注解和包下拦截方法)
- spring之基于aspectj注解aop使用
- Spring AOP使用配置介绍(四):基于@AspectJ注解的aop
- Spring3.0 学习-AOP面向切面编程_Spring AOP的注解模式即Aspectj模式
- spring 4.0 AOP (使用AspectJ的注解方式 的aop实现)简单实例
- Spring AOP之AspectJ的注解方式使用