问题描述
|
我正在尝试建议spring http消息转换器,但是我无法使它正常工作。
@pointcut(\"within(org.springframework.http.converter.xml.MarshallingHttpMessageConverter)\")
public void converterpointcut() {
}
@pointcut(\"execution(* *(..))\")
public void converterMethodpointcut() {
}
@Around(\"converterpointcut() && converterMethodpointcut()\")
public Object aroundConverter(ProceedingJoinPoint iJoinPoint) {
Object aProceed = null;
try {
aProceed = iJoinPoint.proceed();
} catch (Throwable anException) {
anException.printstacktrace();
}
return aProceed;
}
这里有什么问题吗?
解决方法
a)使用
within
,您只建议MarshallingHttpMessageConverter
类的方法,确定要使用的是?
b)要编织一个库类,您需要设置加载时间编织或通过Aspectj编译器运行spring jar(哎呀,不要这样做)。您是否设置了加载时间编织?
c)定义无法正常工作:会发生什么,不会发生什么?
更新:我认为您正在尝试解决错误的问题。不使用AspectJ,只需扩展类(所有方法都不是最终方法)并将扩展的类注册为HttpMessageConverter