Czar
02/23/2020, 10:55 AMDescription:
A component required a bean of type 'java.util.List' that could not be found.
Action:
Consider defining a bean of type 'java.util.List' in your configuration.
Why is that? Doesn't collection autowiring work with Spring Fu?nfrankel
02/23/2020, 10:59 AMSomeConsumer
requires a list
you need to create a dedicated bean of type List<Some>
by yourself
and provide it to the contextCzar
02/23/2020, 11:05 AMbean<_Handler>()
one has to define a bean<List<CommandHandler>> { listOf(ref<_Handler>(), ref<_Handler>(),...) }
?nfrankel
02/23/2020, 11:08 AMCzar
02/23/2020, 11:09 AMMyClass(private val props: MyProps)
application {
beans {
configurationProperties<MyProps>()
bean<MyClass>()
}
}
works exactly as one would expect, props
param is autowired.
That's why I'm baffled, single dependencies are wired in, while collections of beans aren't.
There's explicit, and then there is "do everything by hand, who needs frameworks di containers". The list stuff falls into the latter category, IMO.nfrankel
02/23/2020, 11:17 AMbecause it’s found in the contextparam is autowiredprops
nfrankel
02/23/2020, 11:19 AMCzar
02/23/2020, 11:21 AMnfrankel
02/23/2020, 11:21 AMI want to play with spring-fu 🙂great! remember though it’s an experimental sandbox
Czar
02/23/2020, 11:22 AMnfrankel
02/23/2020, 11:23 AMnfrankel
02/23/2020, 11:23 AMCzar
02/23/2020, 11:23 AMCzar
02/23/2020, 11:25 AMbean<List<Some>>(gatherBeans=true)
or somethingnfrankel
02/23/2020, 11:31 AMCzar
02/23/2020, 12:08 PMbeans {
bean {
SomeConsumer(provider<Some>().toList())
}
}
nfrankel
02/23/2020, 12:10 PM