Aspect不适用于enhancerBySpringCGLIB

时间:2018-02-01 15:03:43

标签: aop spring-aop aspect

面临问题。我的类中的一些字段是注入的,在调试器中我可以看到如下内容: enter image description here

当我尝试将@Aspect映射到SettingService中定义的方法之一时,问题就开始了。像这样:

@Aspect
public class SettingsAspect
{
    @AfterReturning(pointcut = "execution( * package.SettingsService.method(..))", returning = "result")
    public void profilingSettingsAdvice(JoinPoint joinPoint, String result)
    {
        System.out.println(joinPoint.getArgs());
    }

}

我的服务如下:

@Service
@Transactional
public class SettingsService
{    
    @Cacheable(value = "DefaultSettingsCache", key = "#root.methodName")
    public int method()
    {
        return 1;
    }
}

不知道为什么,方法()执行后没有调用方面。神秘的是这个方面适用于其他类/当类注入类型Blablabla $$ EnhancerBySpringCGLIB时它意味着什么? 谢谢。

1 个答案:

答案 0 :(得分:1)

您的建议仅匹配返回String的方法,但您的方法会返回int