您的位置:首页 > Web前端

error Type referred to is not an annotation type 一个解决办法

2018-03-30 09:50 441 查看
最近使用aop想做校验权限功能发现一个问题-->
error Type referred to is not an annotation type: AuthToken
以下是配置文件 <bean id="authTokenAOPInterceptor" class="cn.test.inter.authTokenAOPInterceptor"/>
<aop:config proxy-target-class="true">

<aop:pointcut id="authCheckPointcut" expression="@annotation(AuthToken)"/>

<aop:aspect ref="authTokenAOPInterceptor" order="1"> <aop:before method="before" pointcut-ref="authCheckPointcut"/> </aop:aspect></aop:config>authTokenAOPInterceptor类public class authTokenAOPInterceptor {
WeiXinService ser=new WeiXinService();
private static final String authFieldName = "authToken";

public void before(JoinPoint joinPoint, AuthToken authToken) throws Throwable{
Object[] args = joinPoint.getArgs(); //获取拦截方法的参数
错误原因
authTokenAOPInterceptor类中的before方法方法参数写的是authToken然鹅配置文件写的是
<aop:pointcut id="authCheckPointcut" expression="@annotation(AuthToken)"/>两者改成一致即可也就是 <aop:pointcut id="authCheckPointcut" expression="@annotation(authToken)"/>参考网址: https://stackoverflow.com/questions/8574348/error-type-referred-to-is-not-an-annotation-type
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐