feat: add field injection after constructor injection

Enable @Inject field injection in the bean creation lifecycle. Fields are now injected after constructor injection and before PostConstruct invocation, allowing beans to use both constructor and field injection simultaneously.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Timi
2026-01-13 16:29:20 +08:00
parent c408107c48
commit 597065badc

View File

@ -112,6 +112,8 @@ public class BeanFactory {
} else { } else {
instance = createBeanFromConstructor(definition); instance = createBeanFromConstructor(definition);
} }
// 在构造器注入后执行字段注入
injectFields(instance);
if (definition.getScope() == ScopeType.SINGLETON) { if (definition.getScope() == ScopeType.SINGLETON) {
context.setSingleton(name, instance); context.setSingleton(name, instance);
} }