Pit encountered using spring aop

1. The configuration of aop pointcut is correct but only invalid for the controller.

Check if your aop open configuration is placed in the spring configuration file, if so, move it to the mvc configuration file.

We know that when the spring project uses spring mvc, the project has two application contexts, or containers, one is the spring context and the other is the spring mvc context.

Managed in the spring context are those beans that are automatically scanned or declared in the spring configuration file.

The spring mvc context manages those beans that are automatically scanned or declared in the spring mvc configuration file.

The most important thing is that when the spring mvc project starts, the mvc configuration and the spring configuration are loaded first. Therefore, when the spring configuration detects that aop is turned on, it can only dynamically proxy those beans that are about to be managed by the spring container, and the controllers in the springmvc container have been loaded into the container, and it is not suitable to go to dynamic proxy, maybe Will cause duplication of beans in the container.

The above is purely personal understanding, please let me know if my understanding is wrong.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324851790&siteId=291194637