Skip to content

Spring MVC and AOP: @EnableAspectJAutoProxy needs to be redeclared for each application context [SPR-14753] #19319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Sep 26, 2016 · 0 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: task A general task
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Sep 26, 2016

Manuel Jordan opened SPR-14753 and commented

Hello

According with the following:

Why the class annotated with @EnableAspectJAutoProxy and scanned through RootApplicationContext is practically ignored by ServletApplicationContext?

Exists two possible solutions:

  • the class annotated with @EnableAspectJAutoProxy should be scanned through ServletApplicationContext instead
  • the class annotated with @EnableAspectJAutoProxy should be scanned twice, by RootApplicationContext and ServletApplicationContext

I think each approach has a drawback

Furthermore from the current answer:

Seems that BeanFactoryPostProcessor (which is @EnableAspectJAutoProxy in your case) from parent context not applied to child contexts. To make it work in production you must explicitly define @EnableAspectJAutoProxy in child context too

If that is true is it a bug or is the expected behaviour?

Your explanation about this situation with the solution (extra configuration if exists) should be added in the Spring Framework Reference Documentation, it for the rest of the community.

I think here we have a situation about Best Practices

Thanks by your understanding.


Affects: 4.3 GA

Reference URL: http://stackoverflow.com/questions/39694633/spring-mvc-and-aop-pointcuts-for-controllers-only-works-in-testing-and-not-fo

Issue Links:

Referenced from: commits 0e734d8, 13c2134

Backported to: 4.3.15

@spring-projects-issues spring-projects-issues added status: backported An issue that has been backported to maintenance branches in: core Issues in core modules (aop, beans, core, context, expression) in: web Issues in web modules (web, webmvc, webflux, websocket) type: task A general task labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 5.0.4 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: task A general task
Projects
None yet
Development

No branches or pull requests

2 participants