我们有时候会希望这样:
@拦截的注解
private void 我是被拦截的函数() {
... ....
}
//环绕通知
@Around("...")
public void roundRun(ProceedingJoinPoint joinPoint) {
try {
//执行被拦截的函数
joinPoint.proceed();
//做一些记录或者业务逻辑判断
... ...
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
在“做一...
使用注解实现SpringAop
SpringMVC启动的配置文件,扫描包时不要扫描Service,配置如下:
<context:component-scan base-package="com.xnck">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
</context:component-scan>
Spirng的配置文件,扫描包时不要扫描Controller,配置如下:
<context:component-scan base-package="com.xnck">
&...