How is the configuration meta data provided to the spring container?

Spring Interview Questions Spring, Spring Core, Spring IoC Interview Questions in Spring Interview Questions . 3 years ago

  6   0   0   0   0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

There are 3 ways of providing the configuration metadata. They are as follows:

  • XML-Based configuration: The bean configurations and their dependencies are specified in XML configuration files. This starts with a bean tag as shown below:
<bean id="interviewBitBean" class="org.intervuewBit.firstSpring.InterviewBitBean"> <property name="name" value="InterviewBit"></property> </bean>
  • Annotation-Based configuration: Instead of the XML approach, the beans can be configured into the component class itself by using annotations on the RELEVANT class, method, or field declaration.
    • Annotation wiring is not active in the SPRING container by default. This has to be enabled in the Spring XML configuration file as shown below
<beans><context:annotation-config/><!-- bean definitions go here --></beans>
  • Java-based configuration: Spring FRAMEWORK introduced key features as part of new Java configuration support. This makes USE of the @Configuration annotated classes and @Bean annotated methods. Note that:
    • @Bean annotation has the same role as the <bean/> element.
    • Classes annotated with @Configuration ALLOW to define inter-bean dependencies by simply calling other @Bean methods in the same class.

Posted on 14 May 2022, this text provides information on Spring Interview Questions related to Spring, Spring Core, Spring IoC Interview Questions in Spring Interview Questions. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Tuteehub forum answer Answers

Post Answer

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.