Spring AOP setAdvice 仅针对一种特定方法
我有以下课程:
package x.y.z;
public class MyClass{
public void someMethod(SomeObject object){
//do somethinng
}
public void {
//do somethinng
}
}
现在我想仅在方法 someMethod(SomeObject object, int param1)
上设置 @PointCut
我该怎么做?
更新我正在尝试
@Pointcut("execution(x.y.z.MyClass.someMethod(x.y.z.SomeObject))") but I'm getting not well formed pointcut exception.
I have the following class:
package x.y.z;
public class MyClass{
public void someMethod(SomeObject object){
//do somethinng
}
public void {
//do somethinng
}
}
Now I would like to set @PointCut
only on method someMethod(SomeObject object, int param1)
How can I do it?
Update I'm trying
@Pointcut("execution(x.y.z.MyClass.someMethod(x.y.z.SomeObject))") but I'm getting not well formed pointcut exception.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
切点应该是:
Point cut should be:
将 AspectJ 附加到您的类路径并使用 maven AOP 插件将此 Aspect 编译为字节码,请看这个示例:
Attach AspectJ to your classpath and use maven AOP plugin to compile this Aspect to bytecode, look at this example:
假设我们有一个 @Controller 类:
然后我们必须像这样拦截该方法:
这就是我们拦截特定方法的方式。
Suppose we have a @Controller class :
Then We have to intercept that method like this:
This is how we can intercept specific method.