How will you configure Spring without using XML?

Answered

How will you configure Spring without using XML?

Ninja Asked on 17th September 2018 in Spring.
Add Comment
1 Answer(s)
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

Ninja Answered on 17th September 2018.
Add Comment