Error The type in question is not an annotation type:

I got the following aspect

@Around("execution(public * (@DisabledForBlockedAccounts *).*(..))" + " && @annotation(denyForTeam)") public Object translateExceptionsDenySelectedAccount(ProceedingJoinPoint pjp, Deny deny) throws Throwable { Account account = (Account) pjp.getArgs()[0]; Account selectedAccount = (Account) pjp.getArgs()[1]; if (ArrayUtils.contains(deny.value(), account.getRole())) { if (account.getType().equals(Type.CHEF) && !selectedAccount.getType().equals(Type.CHEF)) { throw new IllegalAccessException(""); } } return pjp.proceed(); } 

and this annotation:

 @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME) public @interface DenyForTeam { Role[] value(); } 

I get the error: error The type in question is not an annotation type: denyForTeam

Why is DenyForTeam not annotated? It is marked as @interface

+4
source share
1 answer

There must be an argument to a method of the name denyForTeam, whose type must be a DenyForTeam annotation. @annotation - bind the annotation to a method argument with the same name.

 @Around("execution(public * (@DisabledForBlockedAccounts *).*(..))" + " && @annotation(denyForTeam)") public Object translateExceptionsDenySelectedAccount(ProceedingJoinPoint pjp, Deny deny, DenyForTeam denyForTeam) throws Throwable { 

If you do not want the annotation to be passed as an argument, include pointcut @DenyForTeam (full text) in the expression.

 @Around("execution(@DenyForTeam public * (@DisabledForBlockedAccounts *).*(..))") public Object translateExceptionsDenySelectedAccount(ProceedingJoinPoint pjp, Deny deny) throws Throwable { 
+12
source

Source: https://habr.com/ru/post/1202161/


All Articles