擴(kuò)展ArgumentResolvers苹粟,這里的interfaceMethodParameter可以修改一下寓免,不然不能支持AliasFor注解
public static MethodParameter interfaceMethodParameter(MethodParameter parameter,
Class annotationType) {
if (!parameter.hasParameterAnnotation(annotationType)) {
for (Class<?> itfc : parameter.getDeclaringClass().getInterfaces()) {
try {
Method method = itfc.getMethod(parameter.getMethod().getName(),
parameter.getMethod().getParameterTypes());
MethodParameter itfParameter = new SynthesizingMethodParameter(method,
parameter.getParameterIndex());
if (itfParameter.hasParameterAnnotation(annotationType)) {
return itfParameter;
}
} catch (NoSuchMethodException e) {
continue;
}
}
}
return parameter;
}
謝謝樓主分享解決了好多問(wèn)題
Spring Cloud實(shí)戰(zhàn)小技巧(解決feign GET傳pojo焦除、繼承接口方法參數(shù)注解等問(wèn)題)源碼地址: https://github.com/charlesvhe/spring-cloud-practice/tree/refactor spring cloud 實(shí)踐...