1

Here, is a detailed post on how spring dependencies on one another can be resolved using @DependsOn --> Controlling Bean Creation Order with @DependsOn Annotation

But some time in the past I have read that spring container creates a DAG of all the beans before it starts initiating or creating the beans. If this is the case, dependencies are automatically addressed using DAG mechanism. So is not @DependsOn redundant.

But if Spring framework is providing one such annotation explicitly, I assume it must carry some real importance. Could someone clarify if there's something I am missing?

samshers
  • 1
  • 6
  • 37
  • 84
  • 1
    That only applies to injection, sometimes you want to have a bean which needs to be created after another one. Like you have a datasource, sessionfactory and use FlyWay to manage the schema. You want flyway to run **before** hibernate initializes. Then you will need an `@DependsOn` to let hibernate wait on flyway to be available. – M. Deinum Aug 31 '20 at 18:30
  • fine got it.. will remove this Q after a while. – samshers Aug 31 '20 at 18:38

0 Answers0