Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

The @DependsOn annotation

Pragya Keshap answered on February 18, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers


The @DependsOn annotation

0

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.

Popularity 1/10 Helpfulness 1/10 Language java
Source: Grepper
Tags: java
Link to this answer
Share Copy Link
Contributed on Feb 18 2023
Pragya Keshap
0 Answers  Avg Quality 2/10


X

Continue with Google

By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
X
Grepper Account Login Required

Oops, You will need to install Grepper and log-in to perform this action.