Spring Boot takes advantage of @ Bean configuration

before using Spring, the interface has multiple implementation classes and uses xml to configure bean, so it is convenient to switch
. But it seems that SpringBoot recommends creating a new bunch of @ Configuration classes. What are the advantages of configuring Bean
in @ Bean way? Isn"t it troublesome to switch?

Apr.18,2022

my own experience: third-party things are registered directly by bean, but generally in the form of xml, so I haven't used @ Bean
for my own implementation is usually in the form of annotations, but not @ Bean, but @ Component lets Spring scan and manage it. If there are multiple interfaces, the
annotations and xml that are switched with @ Qualifier ("name") have their own advantages and disadvantages. Look at the meaning of your team. Just unify


. I think they are all the same. The @ Bean method is more flexible. After all, it is java code

.
Menu