The Spring container manages the bean initialization order. What if you have a bean that depends on another bean? You want to make sure that the dependent bean is initialized before the bean that needs it. @DependsOn helps you to achieve this when you configure beans using Java (not through XML).
You get the exception NoSuchBeanDefinitionException if a bean's initialization order is messed up and because of that the Spring container does not find the dependency.
Let's assume we have a bean named called BazBean that depends on the beans FooBean and BarBean. You can make use of the @DependsOn annotation to maintain the initializing order. The Spring container will follow the instructions and initialize both the FooBean and BarBean beans before creating BazBean.