Introduce PREFERRED_CONSTRUCTORS_ATTRIBUTE on AbstractBeanDefinition

Closes gh-30917
This commit is contained in:
Juergen Hoeller
2023-07-22 16:06:14 +02:00
parent b53034fe62
commit 4786e2bf53
6 changed files with 135 additions and 42 deletions

View File

@@ -575,6 +575,10 @@ public class GenericApplicationContext extends AbstractApplicationContext implem
@Override
@Nullable
public Constructor<?>[] getPreferredConstructors() {
Constructor<?>[] fromAttribute = super.getPreferredConstructors();
if (fromAttribute != null) {
return fromAttribute;
}
Class<?> clazz = getBeanClass();
Constructor<?> primaryCtor = BeanUtils.findPrimaryConstructor(clazz);
if (primaryCtor != null) {