如何在aspectJ中排除getter和setter? [英] How can I exclude getters and setters in aspectJ?

查看:25
本文介绍了如何在aspectJ中排除getter和setter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Maven 项目中有一个 aspectJ 类,它帮助我显示项目中任何被调用方法的开始和结束.我现在尝试排除所有 getter 和 setter.我尝试修改此注释:@Around("execution(public * *(..))经过@Around("execution(public * *(..) && !within(* set*(..))")

I have a class aspectJ in my maven project whitch hepls me to show the Begin and the End of any called method in my project. I try now to exclude all getters and setters. I try modify this annotation: @Around("execution(public * *(..)) by @Around("execution(public * *(..) && !within(* set*(..))")

但它并没有变坏,它在控制台中给了我:

But it doesn't whork and it gives me that in the consol:

 [ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.7:compile (default) on project spb-lceb: AJC compiler errors:
 [ERROR] error at @Around("execution(public * *(..) && !within(* set*(..))")
 Syntax error on token "execution(public * *(..) && !within(* set*(..))", ")" expected

任何想法

推荐答案

我认为这只是一个错字,因为您在 & 之前的执行调用结束时缺少一个 )& 运算符:

I think it's only a typo because you have a mising ) at the end of the execution call before the && operator:

@Around("execution(public * *(..) && !within(* set*(..))")

应该是:

@Around("execution(public * *(..)) && !within(* set*(..))")

试试吧,应该就可以了.

Try it, that should do the trick.

对于以 Get 开头的方法,最好的解决方案是重命名它们以消除这种冲突.

And for the methods that begins with Get the best solution is to rename them to get rid of this conflict.

这篇关于如何在aspectJ中排除getter和setter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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