【发布时间】:2019-09-25 07:35:07
【问题描述】:
我想以不同的方式记录 Controller 和其他包。我知道我可以为此使用 2 种单独的方法,但这两种方法非常相似,所以我想添加一个代码来检查它是否看起来像这样
@Around("controllerPoint() || theRest()")
public Object log(ProceedingJoinPoint joinPoint) throws Throwable {
if( called from controllerPoint() ) {
execute this short section of code # (1)
}
// rest of code
这段代码会是什么样子?
另外,如果在我执行 (1) 之后,我想在执行其他包时再次将一个变量传递给同一个方法,我该怎么做?
【问题讨论】:
-
不要...只需编写 2 个方法并将共享的内容提取到您从两者调用的方法中。尝试将所有这些都硬塞到一个方法中会更容易推理。
标签: spring-boot logging spring-aspects