As Spring 3.0 support annotation to configure beans using @configuration and @bean there is no need of declare beans in the xml file right? so i guess in future the class XmlBeanFactory will be deprecated? Any comments on which way is more efficient?
This is a general trend with more than just Spring and comes under the general heading of "zero configuration". You can see similar stuff in Java EE, for example.
However, annotations by themselves have problems, since if they were left unattended, they'd require hard-wiring of component relationships and configuration parameters. That would remove a lot of Spring's flexibility to allow reusable code, plugin components, and special wiring for test frameworks.
So the actual process (in Spring and elsewhere) is that if an XML file exists, it will override the annotations. That way you can take a "management by exception" approach, code the information in the Java files (where appropriate), but still be able to customize it by external directives in the XML file.
So XML is not obsolete, just no longer the only way to do things.
An IDE is no substitute for an Intelligent Developer.
Joined: Jun 11, 2007
Thankx Tim for the reply...by the way what you mean by "if they were left unattended"?