Here is an example of what i want to understand :
@Component
class Foo {
@Autowired B b; // B is @Component
@Autowired C c; // C is @Component
@Autowired A a; // A is @Component
}
What is the ordering that spring takes for injecting A, B and C beans in Foo bean :
- It starts with B beacause it is the first declared ?
- It starts with A because by default it is the first in alphabetical order ?
- It injects beans randomly ?
I understand that @Autowired is not recommanded and we should use constructor for dependency injection instead but just i want to know how spring behaves by default.
Thanks