File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between Annotation based configuration and Java based configuration

 
Hardik Patel p
Ranch Hand
Posts: 40
Hibernate Java Tomcat Server
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is difference between Annotation based configuration and Java based configuration ? please help me.
 
Surendra Kumar
Ranch Hand
Posts: 236
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 40
Hibernate Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 236
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Hardik Patel p
Ranch Hand
Posts: 40
Hibernate Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok I understood. Thank you Bill Gorder, Surendra Kumar
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic