Which pointcut expression correctly matches all methods in classes within the package com.example.service and its subpackages?
Remember that .. matches subpackages and any number of arguments.
The expression execution(* com.example.service..*(..)) matches all methods in com.example.service and any subpackage. Option C matches only classes directly in service package, not subpackages. Option C matches only classes directly in service package but not methods. Option C uses invalid syntax **.
Given the following Spring AOP around advice, what will be printed when the method processOrder() is called?
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
System.out.println("Start: " + joinPoint.getSignature().getName());
Object result = joinPoint.proceed();
System.out.println("End: " + joinPoint.getSignature().getName());
return result;
}Think about the order of statements before and after proceed().
The advice prints "Start" before calling the actual method with proceed(), then prints "End" after the method completes. So the output is "Start: processOrder" followed by "End: processOrder".
Which of the following Spring configuration snippets correctly enables AspectJ auto-proxying and declares a logging aspect bean?
Enabling AspectJ auto-proxying is required for aspects to work.
Option B correctly uses @EnableAspectJAutoProxy and declares the aspect bean. Option B misses enabling AOP. Option B misses configuration class and bean declaration. Option B enables transaction management, not AOP.
A developer created a logging aspect with @Around advice but no logs appear when methods run. What is the most likely cause?
Check if the aspect is recognized by Spring AOP.
Without @Aspect annotation, Spring does not recognize the class as an aspect, so advice is not applied. Private methods are not proxied by Spring AOP, but that alone doesn't prevent logs if public methods are called. Using System.out.println still prints output. Missing web starter does not affect AOP.
Which advice type is best suited to measure and log the execution time of a method in Spring AOP?
Think about needing to capture time before and after the method runs.
@Around advice wraps the method call, allowing code to run before and after the method. This lets you record start time before and end time after, calculating execution duration. Other advice types run only before or after, not both.