Meaningless Drivel is fun!*
The moose likes Spring and the fly likes Difference between Annotation based configuration and Java based configuration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Difference between Annotation based configuration and Java based configuration" Watch "Difference between Annotation based configuration and Java based configuration" New topic
Author

Difference between Annotation based configuration and Java based configuration

Hardik Patel p
Ranch Hand

Joined: Jan 23, 2014
Posts: 32

what is difference between Annotation based configuration and Java based configuration ? please help me.
Surendra Kumar
Ranch Hand

Joined: Jul 04, 2006
Posts: 235
You mean annotation based and xml based configuration?
Annotations are declared in Java code.
Another way is that the configurations defined in xml file.
Hardik Patel p
Ranch Hand

Joined: Jan 23, 2014
Posts: 32

Mr. Surendra Kumar

I thought same but just see this

http://www.tutorialspoint.com/spring/spring_java_based_configuration.htm
http://www.tutorialspoint.com/spring/spring_annotation_based_configuration.htm


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: 235
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.
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1646
    
    7

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.

So it is either Java(annotation) config or it is XML.


[How To Ask Questions][Read before you PM me]
Hardik Patel p
Ranch Hand

Joined: Jan 23, 2014
Posts: 32

ok I understood. Thank you Bill Gorder, Surendra Kumar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between Annotation based configuration and Java based configuration
 
Similar Threads
The difference between field-based access and property-based access
Which is the best way to declaring architecture in struts2
Difference between @WebService and @WebServiceProvider
@Resource vs @Component
What are the other ways of Wiring in spring, apart from XML?