Card 07/ 07

RecapDifficulty: Advanced1 min

Recap: Wiring Beans Together

Constructor injection, stereotypes, ambiguous beans and @Bean methods, with where each was.

Wiring beans together comes down to the five ideas below, each listed with the card that covers it.

What the topic established, and which card it was on
The ideaWhere
Constructor injection is the default: no half-built objects, every dependency in one placeConstructor Injection: Why It Is Spring's Default
A class's only constructor needs no @AutowiredConstructor Injection Example: One Constructor, No @Autowired
The four stereotypes register beans identically; @Repository also translates exceptions@Component, @Service, @Repository and @Controller Compared
Two candidates for one parameter stop startup; @Primary sets a default, @Qualifier picks oneAmbiguous Beans: Two Implementations of One Interface
A class you cannot annotate becomes a bean through a @Bean method@Bean Methods Example: Registering a Class You Cannot Annotate

Most startup failures in a Spring application are one of these: a missing bean, two candidates for one parameter, or a class nobody told the container about.