xml里面的配置 <aop:aspectj-autoproxy/> <context:component-scan base-package="com.xx"/> java代码 @Aspect @Component public class LogAdvice{ @After("@annotation(testLog)") public void testLog(JoinPoint joinPoint,TestLog testLog)throws Exception{ System.out.println(testLog.remark()); } } @Target({ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface TestLog{ String remark() default ""; } @Service public class test{ @TestLog(remark="测试") public void testService(String str)throws Exception{ //TODO } }
自定义注解的例子
猜你喜欢
转载自dongxylove.iteye.com/blog/2286710
今日推荐
周排行