0
ではありません私はポイントカット春AOPエラー:エラーの種類に言及注釈型
@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());
}
}
を作るしようとするとそれがエラーを投げたアクション
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Action {
String name();
}
の注釈を宣言: javaの.lang.IllegalArgumentException:参照されたエラータイプがアノテーションタイプではありません:com $ wisely $ highlight_spinrg4 $ ch1 $ aop $アクション
"アクション"を設定するために@interfaceを使用して以来、注釈として。誰も助けてくれますか?
タイプがパッケージ名になっていると思いますか? 'spinrg4'は' spring4'でしょう。 –
それは問題です!どうもありがとう! – jiazhong