AOP annotation does not work out when a class inherits an interface

@Aspect
@Component
@DependsOn("springConfig")
public class CatchInternetLossExceptionHandler {
    protected final Log LOG = LogFactory.getLog("CatchInternetLossException");

    @Around(value = "@annotation(CatchInternetLossException)")
    public Object InternetLossExceptionCatch(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("Internet loss");
        return joinPoint.proceed();
    }

}

@Configuration
@EnableScheduling
@EnableAspectJAutoProxy(proxyTargetClass = true)
@ComponentScan("com.ro.terminal")
public class SpringConfig {
}

@Component
public class Hello implements TerminalConstants {

    @CatchInternetLossException
    public final void qwe() {
        System.out.println("qqqqqq");
    }

}

I am trying to implement an annotation so that when I call a method I work out some additional code. in this example, just outputting the string to the console.

In the Hello class, the method that is marked with the desired annotation is called.

If the Hello class is not implimentit any interfaces it works, but if it implements the interface code does not work (for not working is meant that the method fulfills no errors, just the additional functionality of the annotations do not).

Question: how to make that method of working out and in case when you implement interfaces?

I read that you need to enable cglib support, but in the configuration class when I set the annotation @EnableAspectJAutoProxy(proxyTargetClass = true)as before, there was no expected result.

Spring version – 4.3

Asked on January 19, 2020 in Programming.
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.