方面不适用于 enhancerBySpringCGLIB
Aspect not work with enhancerBySpringCGLIB
遇到问题。我的 classes 中的一些字段被注入,在调试器中我可以看到类似这样的东西:
当我尝试将 @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;
}
}
不知道为什么,方面在 method() 执行后没有被调用。神秘之处在于该方面与其他 classes/ 注入类型 Blablabla$$EnhancerBySpringCGLIB 时 class 是什么意思?
谢谢。
您的建议仅匹配返回 String
的方法,但您的方法 returns 匹配 int
.
遇到问题。我的 classes 中的一些字段被注入,在调试器中我可以看到类似这样的东西:
当我尝试将 @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;
}
}
不知道为什么,方面在 method() 执行后没有被调用。神秘之处在于该方面与其他 classes/ 注入类型 Blablabla$$EnhancerBySpringCGLIB 时 class 是什么意思? 谢谢。
您的建议仅匹配返回 String
的方法,但您的方法 returns 匹配 int
.