Both uses annotation, I also referred documentation of spring but same things is there. Please help

Thank you
Hardik

Surendra Kumar
Ranch Hand

Joined: Jul 04, 2006
Posts: 236

posted Jan 24, 2014 05:24:02

0

Yes, even then it's Java (i.e., annotation) based configuration versus the XML-based configuration.
(Not java based vs annotation based as per your original question)
You read the documentation so now you know.
Beans can be defined in an XML file or using Java classes with @Configuration annotation.

The official Spring documentation refers to configuring your beans using a Java class annotated with @Configuration and containing @Bean methods as 'Java Configuration'. This allows you to be absolutely free of all XML in your application (at least as far as Spring goes). This support was added in Spring 3.0, and has gotten more powerful since then.

It looks like the tutorials you are looking at have made a distinction on using annotations such as @Autowired and @Component for DI and scanning for and for auto-configuring beans. This support was added in Spring 2.5 and allowed users to use these annotations to reduce the amount of XML configuration they needed to do. Pre 2.5 you had to define every bean in XML. He is calling this Annotation based configuration.

These days as Surendra mentioned you either are either providing meta data in your Java class (by using annotations) or you are defining them in XML. You can of course mix the 2 approaches as well.