Код: Выделить всё
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Action {
String name();
}
< /code>
Когда я попытался сделать точку < /p>
@Aspect
@Component
public class LogAspect {
@Pointcut("@annotation(com.wisely.highlight_spinrg4.ch1.aop.Action)") //it failed here
public void annotationPointCut() {}
@After("annotationPointCut()")
public void after(JoinPoint joinPoint) {
MethodSignature signature = (MethodSignature)
joinPoint.getSignature();
Method method = signature.getMethod();
Action action = method.getAnnotation(Action.class);
System.out.println("Annotation Interpreter " + action.name());
}
@Before("execution(*com.wisely.highlight_spring4.ch1.aop.DemoMethodService.*(..))")
public void before(JoinPoint joinPoint) {
MethodSignature signature = (MethodSignature)
joinPoint.getSignature();
Method method = signature.getMethod();
System.out.println("Method Interpreter" + method.getName());
}
}
< /code>
Это бросил ошибку: < /p>
java.lang.IllegalArgumentException:
error Type referred to is not an annotation type:
com$wisely$highlight_spinrg4$ch1$aop$Action
Подробнее здесь: https://stackoverflow.com/questions/367 ... ation-type