I'm new in Spring Boot AOP.
Does an AOP method annotated with @Before run before java validation annotations (such as @NotNull)?
I have some other custom validations that need to run for every request but I need to run these validations after java validation annotations run.
Which one will run first?
my Controller:
@RestController
@RequestMapping("/users")
public class UserController {
private final UserService userService;
@Autowired
public UserController(UserService userService) {
this.userService = userService;
}
@PostMapping(value = "")
public List<User> getAllUsers(@Valid @RequestBody User user) {
return userService.getAllUsers();
}
}
and my advice:
@Aspect
@Component
public class AspectConfig {
@Pointcut(value = "within(@org.springframework.web.bind.annotation.RestController *)")
public void restControllers() {
}
@Before(value = "restControllers()")
public void logRequest(JoinPoint joinPoint) {
...
}
}