'What is the default autowiring ordering in a single bean class

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 :

  1. It starts with B beacause it is the first declared ?
  2. It starts with A because by default it is the first in alphabetical order ?
  3. 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



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source