Anuj Jain
Anuj Jain

Reputation: 245

What will be the spring bean creation flow for nested @component annotations

@Component
public classA {

  @Component
  public static classB {
  }

  @Component
  public static classC {
  }

}

what will be the order for spring bean creation here?

Upvotes: 2

Views: 905

Answers (1)

DavidR
DavidR

Reputation: 6952

When scanning classes Spring will check for dependencies to determine creation order. ClassB and ClassC will get created before ClassA but which of the other two classes will get created first is unspecified, unless one of them also has a dependency on the other.

Upvotes: 2

Related Questions