philhan philhan - 7 months ago 57
Java Question

Spring aspect call on custom annotation on interface method

I have this interface:

public interface FakeTemplate {

void foo() {



And this implementation of the interface:

public FakeImpl implements FakeTemplate {

public void foo() {
//Do Stuff


And this aspect:

public class CustomAspect {

@Before(value = "@annotation(com.fake.CustomAnnotation)")
public void doStuffBefore(JoinPoint joinPoint} {



I'm using spring with AspectJ enabled using:
@EnableAspectJAutoProxy(proxyTargetClass = true)

My issue is that the aspect
method is not being called before the execution of FakeImpl's
method. It Does work when I put the
instead of
, but I'd much prefer to put the annotation on
as it's in a separate API package and I've kind of delegated it as the place where I put all my annotations.

I'd also like to ensure that the
is called on every class that implements
without remembering to put the annotation on all the implementation classes themselves.

Is there any way to get the advice to be called if the annotation is only on the interface class?


Annotation inheritance doesn't work for methods in java. But you can use other pointcut expression, something like execution(public *