引用的错误类型不是注释类型: [英] error Type referred to is not an annotation type:

查看:32
本文介绍了引用的错误类型不是注释类型:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了以下方面

@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();
}

还有这个注解:

@Target({TYPE, METHOD, FIELD})
@Retention(RUNTIME)
public @interface DenyForTeam
{

Role[] value();

}

我收到错误:所指的错误类型不是注释类型:denyForTeam

I get the error:error Type referred to is not an annotation type: denyForTeam

为什么 DenyForTeam 没有注释?它用@interface

Why is DenyForTeam no Annotation? It is marked with @interface

推荐答案

需要有一个名称为 denyForTeam 的方法参数,其类型应为 DenyForTeam 注释.@annotation - 将注解绑定到具有相同名称的方法参数.

There needs to be a method argument of the name denyForTeam whose type should be 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
{

如果您不希望将注释作为参数传递,则在切入点表达式中包含 @DenyForTeam(完全限定).

If you don't want the annotation passed as an argument then include the @DenyForTeam (full qualified) in the pointcut expression.

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

这篇关于引用的错误类型不是注释类型:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆