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

Configuring beans using Java

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

Contents


More Related Answers

  • bean in spring
  • java bean
  • Explain Spring Beans?
  • spring boot bean configuration
  • java beans
  • @Bean java spring
  • bean in spring
  • set bean properties
  • Defining beans
  • What are Spring beans?
  • What are Spring beans?

  • Configuring beans using Java

    0

    Spring 3 introduced the @Configuration, @Bean, @import, and @DependsOn annotations to configure and define Spring beans using Java.

    You have already learned about the @Configuration and @Bean annotation in the Defining beans section. Now, you will explore how to use the @import and @DependsOn annotations.

    The @Import annotation is more useful when you develop an application without using autoconfiguration.

    The @Import annotation

    This is used for modularizing configurations when you have more than one configuration class. You can import the bean's definitions from other configuration classes. It is useful when you instantiate the context manually. Spring Boot uses autoconfiguration, therefore you don't need to use @Import. However, if you want to instantiate the context manually, then you would have to use @Import to modularize the configurations.

    Let's say the configuration class FooConfig contains FooBean and the configuration class BarConfig contains BarBean. The BarConfig class also imports FooConfig using @Import:

    Popularity 1/10 Helpfulness 1/10 Language java
    Source: Grepper
    Tags: java using
    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.