Image via Wikipedia Annotations have changed every thing and lots of version updates/upgrades are made just to support them. Yes they have developers to get rid of lots of xml schemas and files at the same time,"Annotations have been more successful than XML" But are those XML files really bad ?
Many of you might remember at the spring 1.2.X series there is a strong voice like: easy,quick configurations and implementations with spring Yes in fact that was totally true. It really used POJOs as bean containers. And it works really fine. While using these spring versions you did not usually need to make any import statements for any spring package/class/interface sample classes below were shown as best practices:
Annotations came to JDK with JDK5 (2004) since then they evaluated and are accepted so widely and even became more powerful and useful than XML in just 4 years. While you are developing a project with java at any scale you'll need a very large number of XML files defined in very different API's and DTD/XSDs. Which makes configuration very complex. eg:struts.xml,tiles.xml,validation.xml,hibernate.cfg.xml,spring-context.xml,web.xml,and so on Although it is easy to read and modify there are lots files :( Now with annotations:
Image via Wikipedia JAXB is a java framework to XML-Java transformations. JAXB is 2.1 has a very simple API like castor and jibx And annotation driven transformers. Although those configurations can be written manually JAXB has a code generator to generate java files from XSD files. Here is sample JAXB tutorial using maven2: