Reputation: 299
With deployment descriptors I can easily configure the beans and other servlet information during deployment without the need to open the code and compile it again.
Then why annotations replaced the deployment descriptors, annotations are followed in spring, JSF 2.0 and hibernate too.
Can any one tell me the main advantages of annotations over deployment descriptors and other config files like( beans.xml, spring-config.xml, struts.xml)?
Upvotes: 3
Views: 2090
Reputation: 6237
First, there's a trend to replace a kind of dual language programming (Java + XML) with only one (Java).
And it is sometimes true - it's easy to analyze and prototype an application, when everything (data, methods and metadata/annotations) are in one place.
But there's also hidden truth. XML has it's use and in Spring there's a kind of XML DSL - dedicated XML tags/attributes to configure particular aspects of application (Security, MVC, Transaction configuration, AOP). And using this it's much easier to write and (what's more important) read and maintain such configuration.
And one, sometimes forgotten aspect. With XML you can have two objects of the same class configured differently. With annotations, you put them on the class, so every object of such class is generally the same.
Upvotes: 5