AOP notification:
By configuring spring, the notification is inserted before or after the method is executed, and the printing log information, exception information, and obtaining the class name, method name, parameters, etc. are added.
1. Pre-notification;
2. Post-notification;
3. Surround notification;
4, return notification;
5, exception notification;
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- define notification --> <bean id="studentServiceAspect" class="com.fx.advice.StudentServiceAspect"></bean> <!-- define business class --> <bean id="studentService" class="com.fx.service.impl.StudentServiceImpl"></bean> <!-- Business class configuration notification--> <aop:config> <aop:aspect id="studentServiceAspect" ref="studentServiceAspect"> <!-- Pointcut expression, matching java under the package path --> <aop:pointcut expression="execution(* com.fx.service.*.*(..))" id="businessService"/> <!-- Pre-Notification--> <aop:before method="doBefore" pointcut-ref="businessService"/> <!-- Post notification --> <aop:after method="doAfter" pointcut-ref="businessService"/> <!-- Surround Notification --> <aop:around method="doAround" pointcut-ref="businessService"/> <!-- return notification--> <aop:after-returning method="doAfterReturning" pointcut-ref="businessService"/> <!-- Exception notification--> <aop:after-throwing method="doAfterThrowing" pointcut-ref="businessService" throwing="ex"/> </aop:aspect> </aop:config> </beans>