alibaba / alibaba/spring-context-support
AbstractAnnotationBeanPostProcessor无法装载含有多个参数的类问题
- Dominant language
- Java
- Stars
- 155
- Forks
- 87
- PR merge metrics
- No merged PRs in 30d
Description
类路径: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> ,便于多个参数的情况下可以正常装到容器
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor, reviewing resolveInjectedType and resolveTypeArgument together with Spring's ResolvableType handling. Reproduce the failure for a class with multiple type parameters and determine how the injected types should be represented. Done means such classes can be loaded into the container without the current error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100