import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
@Aspect
public class LoggingAspect {
@Before("execution(* com.example.app.service.*.*(..))")
public void logBefore(JoinPoint joinPoint) {
System.out.println("Before executing method");
}
@Pointcut("execution(* com.example.app.service.*.*(..))")
private void selectAll() {}
// other advice methods
}
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.9.7</version>
</dependency>
<aop:aspectj-autoproxy/>
<bean id="loggingAspect" class="com.example.app.aspect.LoggingAspect"/>