Gopal S Akshintala
04/17/2021, 8:28 AMnfrankel
04/17/2021, 8:41 AMGopal S Akshintala
04/17/2021, 9:44 AMGopal S Akshintala
04/17/2021, 9:47 AMnfrankel
04/17/2021, 10:03 AMLuca Piccinelli
04/17/2021, 8:38 PMnfrankel
04/18/2021, 9:19 AMJukka Siivonen
04/18/2021, 8:54 PMthanksforallthefish
04/19/2021, 6:49 AMNote that autowiring by name if even worse, since bean names have a probability of collision, even across different type hierarchies.true story, I get itchy when I see
@Qualifier
, now try to decorate the bean and either you have to change at injection point or you have to change the original bean to give him a different name. autowiring by name always seemed to me one of those cases where you write code with abstractions because you were told so but then you actually want a very specific implementation to be used in a specific contexts, de facto negating the abstraction.thanksforallthefish
04/19/2021, 6:52 AM@Bean
fun aBean() = OutDecorator(InDecorator(ActualImpl()))
while I saw people having all 3 as spring beans, then I see it can be a problem.nfrankel
04/22/2021, 8:22 AMprivate
, internal
and public
but we’re happy to expose beans
creating a bean means it will be registered in the context
and anybody can access it
i believe than when you realize that
you try to make as many beans “anonymous”nfrankel
04/22/2021, 11:39 AMnfrankel
04/22/2021, 11:39 AMLuca Piccinelli
04/22/2021, 7:43 PMExplicit dependency injection is - guess what, explicitly defining a single bean to match the required dependency. Even better, if Java Configuration is used, it is validated at compile time.
Here by "explicit DI" do you mean @Bean inside a @Configuration vs @Component?nfrankel
04/22/2021, 7:45 PMnfrankel
04/22/2021, 7:46 PMLuca Piccinelli
04/22/2021, 7:53 PMnfrankel
04/22/2021, 8:37 PM@Bean
public A a() { return new A(); }
@Bean
public B b(A a) { return new B(a); }
nfrankel
04/22/2021, 8:39 PM@Bean
public B b(A a) { return new B(new A()); }
nfrankel
04/22/2021, 8:40 PMA
is only necessary for B
, why should we register it in the context?nfrankel
04/22/2021, 8:40 PMLuca Piccinelli
04/23/2021, 5:07 AMLuca Piccinelli
04/23/2021, 5:08 AMLuca Piccinelli
04/23/2021, 5:09 AMnfrankel
04/23/2021, 5:32 AMBy the way I totally agree with you... and debate many time with some colleagues that you shouldn’t use @Autowire just because it existunfortunately: