Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbstractAnnotationBeanPostProcessor无法装载含有多个参数的类问题 #48

Open
saaserp opened this issue Nov 2, 2021 · 0 comments

Comments

@saaserp
Copy link

saaserp commented Nov 2, 2021

类路径:com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor
方法:
private Class resolveInjectedType(Object bean, Field field) { Type genericType = field.getGenericType(); if (genericType instanceof Class) { // Just a normal Class return field.getType(); } else { // GenericType return resolveTypeArgument(getTargetClass(bean), field.getDeclaringClass()); } } @nullable public static Class resolveTypeArgument(Class clazz, Class genericIfc) {
ResolvableType resolvableType = ResolvableType.forClass(clazz).as(genericIfc);
if (!resolvableType.hasGenerics()) {
return null;
}
return getSingleGeneric(resolvableType);
}
resolveTypeArgument 遇到一个类有多个参数的时候,会导致报错;
建议resolveInjectedType返回类型为List<Class<?>> ,便于多个参数的情况下可以正常装到容器

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant