How will you configure Spring without using XML?
Answered
How will you configure Spring without using XML?
Best answer
Spring provides an alternate means to configure beans through use of Java Annotations. Some of the common annotations and their usage is below:
@Configuration – The class having this annotation can be used by Spring container as a source of bean definitions
@Bean – The method having this annotation returns an object that will be treated as a bean by spring container
@Import – Allows loading of bean definitions from another configuration class.
@Scope – Used along with @Bean annotation to configure scope for the bean