Comparison between the spring annotation mechanism and the XML configuration mechanism

Source: Internet
Author: User

Advantages and disadvantages of XML configuration:

The advantages are:
1. The XML configuration method further reduces the coupling, making the application easier to extend, even if the configuration file is further modified and does not require engineering modification and recompilation.
2. When dealing with large volumes of traffic, it should be better to use XML configuration. 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.

3.xml, Care: The overall business relationship, maintainability.

Disadvantages are:
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:

The advantages are:
1. In the class file, the maintenance cost can be reduced, the annotation configuration mechanism is obviously simple
2. No third-party parsing tools are required, and Java reflection technology is used to complete the task
3. Editing period can verify correctness, error becomes easy
4. Improve development efficiency

Disadvantages are:
1. If you need to modify the annotation, then recompile the entire project
2. The relationship between business classes is not as easy to grasp as the XML configuration.
3. If more annotation in the program, directly affect the quality of code, the code of the brevity has a certain impact.

Comparison between the spring annotation mechanism and the XML configuration mechanism

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.