0

Why hibernate,spring and struts provide annotation based configuration and what is difference between xml configuration and annotation based configuration, please tell with example?

aish
  • 9
  • 1
  • This doesn't really fit into the SOF format - I think you are better off doing some research on your own. – Jan Groth Jul 03 '15 at 04:51
  • 2
    No basic difference but annotations improve readability as you don't have to navigate to the xml to know what is been injected/what is the behavior of bean(i.e. Repository/Service/Controller) easy to manage. The same functionality can be achieved using xml can be achieved using annotations as well – Bilbo Baggins Jul 03 '15 at 04:51
  • Because of this: http://www.annotatiomania.com (sorry, I just had to...) – Mathias Begert Jul 03 '15 at 05:04

2 Answers2

0

You need not code lots and lots of xml , instead concentrate on your business logic, rather configuring the xml all the time.

Answer already here .. Xml configuration versus Annotation based configuration

Community
  • 1
  • 1
Kalyan Chavali
  • 1,330
  • 8
  • 24
0

An advantage of XML configuration is that it is separate from the code, so that the source code can focus on the business logic and isn't cluttered with "glue" code to put all the components together. Another advantage is that you can change it without recompiling the code.

On the other hand: Some people dislike XML, and having a set of XML configuration files that reference each other can become hard to understand and to navigate. Having the configuration of a class close to that class (in the source file itself) can make it more clear which part of the configuration belongs to which class.

Jesper
  • 202,709
  • 46
  • 318
  • 350