Add core-di: constructor vs setter vs field injection and @Autowired candidate resolution on Boot 4.1
Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JoVmf2fWvcpoXndcDSwRf7
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
# A List<Plugin> injection point when zero Plugin beans exist
|
||||
|
||||
|
||||
--- required List<Plugin>, zero Plugin beans ---
|
||||
single constructor param : started (empty list injected)
|
||||
@Autowired ctor + no-arg ctor : started (empty list injected)
|
||||
FieldInjected : FAILED NoSuchBeanDefinitionException
|
||||
No qualifying bean of type 'java.util.List<com.ankurm.coredi.resolution.Plugin>' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
|
||||
SetterInjected : FAILED NoSuchBeanDefinitionException
|
||||
No qualifying bean of type 'java.util.List<com.ankurm.coredi.resolution.Plugin>' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
|
||||
|
||||
--- ways to make an absent collection legal ---
|
||||
Optional<List<Plugin>> : isPresent=false
|
||||
@Nullable List<Plugin> : value=null
|
||||
ObjectProvider<Plugin> -> list : []
|
||||
@Autowired(required=false) list: []
|
||||
Reference in New Issue
Block a user