• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

311
Views
Spring Aspectj @Before all rest método

Antes de la primavera, presente @GetMapping , solo hay una anotación que nos importa @RequestMapping , por lo tanto, este aspecto funciona

 @Before("within(aa.bb.*.rest..*) && execution(public * *(..)) && @within(org.springframework.web.bind.annotation.RestController) && @annotation(org.springframework.web.bind.annotation.RequestMapping)")

Pero después podemos usar @GetMapping , @PostMapping , este punto no funciona, pero estas anotaciones tienen una meta anotación @RequestMapping .

¿Hay alguna forma de interceptar fácilmente todos los @RequestMapping / @{Get,Post,Put,Patch,..}Mapping ?

about 3 years ago · Santiago Trujillo
1 answers
Answer question

0

¡Encontré que esta sintaxis aquí funciona para mí!

 @Pointcut("execution(@(@org.springframework.web.bind.annotation.RequestMapping *) * *(..))") public void requestMappingAnnotations() { }

También puedo enumerarlos a todos.

 @Pointcut("within(aa.bb.*.rest..*) && @within(org.springframework.web.bind.annotation.RestController)") public void restControllers() {} @Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping) " + "|| @annotation(org.springframework.web.bind.annotation.GetMapping)" + "|| @annotation(org.springframework.web.bind.annotation.PostMapping)" + "|| @annotation(org.springframework.web.bind.annotation.PatchMapping)" + "|| @annotation(org.springframework.web.bind.annotation.PutMapping)" + "|| @annotation(org.springframework.web.bind.annotation.DeleteMapping)" ) public void mappingAnnotations() {} @Pointcut("execution(@(@org.springframework.web.bind.annotation.RequestMapping *) * *(..))") public void requestMappingAnnotations() { } @Before("restControllers() && requestMappingAnnotations()") public void onExecute(JoinPoint jp) {}
about 3 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error