I am trying to log my @Controller request (both request name and data ) using spring @Aspect in spring boot . The issue is that when using @Valid with no valid data the method is not execute since the argument resolving happened before.
I have also tried the following solutions ,but they didn't worked for me:
- Implementing Filter - It required to cache the Stream and Implement your own Servlet Stream + It disable the abbility to use ThreadContext in order to identify the request in all logs in logic.
- Interceptor - I was trying to add Interceptor this has two problems first extends WebMvcAutoConfiguration.EnableWebMvcConfiguration or WebMvcConfigurationSupport cause the Autoconfig not to work secondly in order to get the data I need to add it in a later phase since in pre handle it not readed yet .I can use ThreadContext and @InitBinder for that i guess but it still leave me with the first problem and very not clean solution.
If anyone has other idea or good suggestion on how to use @Aspect with @Valid it will be very helpful . Thanks
Aucun commentaire:
Enregistrer un commentaire