How is a bean added to a spring application?



How is a bean added to a spring application?..

Answer / Monika Sirohi

You can add a bean to a Spring Application by defining its configuration in an XML file or using annotations. If you're using XML, the bean definition is included in the 'beans' element of the Spring configuration file. If you're using annotations, the bean class must be annotated with @Component, and the bean can be registered automatically if the component scan is enabled.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Spring Framework Interview Questions

What are the different modules in spring framework?

1 Answers  


What is proxy in spring aop?

1 Answers  


What is jdbctemplate in spring? And how to use it?

1 Answers  


Is spring data jpa an orm?

1 Answers  


What is the basic concept of spring?

1 Answers  


What is spring boot starter jdbc? : Spring Boot

1 Answers  


Which is good to use – constructor or setter-based dependency?

1 Answers  


What is mockito junit?

1 Answers  


What is service layer in spring mvc?

1 Answers  


How many modules are there in spring framework and what are they?

1 Answers  


What is stateful bean in spring?

1 Answers  


What is the ioc in spring?

1 Answers  


Categories