Springboot unit test aop fails

Background : AOP was implemented using springboot, and the logic of aop was tested through the controller interface, but the logic of aop failed during unit testing, and the logic of debug did not follow.

The reasons are as follows : 1.@EnableAspectJAutoProxy is an annotation to enable the aop function.

                  2. Springboot turns on @EnableAspectJAutoProxy(true) by default .

                  3. But in unit testing, the annotation @EnableAspectJAutoProxy is not turned on by default , so the aop function is not turned on, and the aop logic cannot be executed.

Solution : Annotate @EnableAspectJAutoProxy(true) on the unit test class to enable the aop function.

Guess you like

Origin blog.csdn.net/Mint6/article/details/105001618