Advantages and disadvantages of spring configuration mechanism-Annotation vs XML

Source: Internet
Author: User

Transfer from http://tianzongqi.iteye.com/blog/1458002

Advantages and disadvantages of XML configuration:

  • Advantages:
  1. The XML configuration approach further reduces coupling, making the application easier to scale, even if the configuration file is further modified and does not require engineering modification and recompilation.
  2. The XML configuration should be better when dealing with large volumes of traffic. Because XML is a clearer indication of the relationship between the various objects, calls between the various business classes. At the same time, the relevant configuration of spring can be at a glance.
    Of course, some people will say that with XML configuration, the large volume of business will make the XML file too large, not easy to view. This allows us to write more than one XML configuration file with business decomposition.
  • Disadvantages:
  1. Configuration file reading and parsing takes a certain amount of time, too many configuration files are difficult to manage, the correctness of the configuration can not be verified, increasing the test difficulty.


Advantages and disadvantages of annotation configuration:

  • Advantages:
  1. In the class file, maintenance costs can be reduced, and the annotation configuration mechanism is clearly simple
  2. No third-party parsing tools are required, and Java reflection technology is used to accomplish tasks
  3. Edit period can verify correctness, error becomes easy
  4. Improve development efficiency
  • Disadvantages:
  1. If you need to modify the annotation, then recompile the entire project
  2. The relationships between business classes are not as easy to grasp as the XML configuration.
  3. If the annotation is more in the program, it directly affects the quality of the code, which has a certain effect on the brevity of the code.

Advantages and disadvantages of spring configuration mechanism-Annotation vs XML

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.