Describes in detail the role of XML in JAVA projects

Source: Internet
Author: User
General programming is mostly used to store configuration information. for JDBC, you can write the database connection string to xml. to modify the data source, you only need to modify the xml. you do not need to re-compile the java file, these configuration information is put together. When someone else reads the code you write, it makes it easier for many java projects. xml files are generally used to store some configuration information.
General programming is mostly used to store configuration information. for JDBC, you can write the database connection string to xml. to modify the data source, you only need to modify the xml. you do not need to re-compile the java file, the configuration information is put together, so it is much easier for others to read your code.
In addition to configuration information, xml in the framework can also write some ing relationships, which is actually a configuration information. for struts, the xml configuration corresponds to the relationship between the page url and the background java class (action). you only need to change the xml file when configuring and modifying it, there is no need to search java code one by one
After the java project is completed, each module should be independent, and the relationship between modules can be maintained using xml. spring is such a framework.

A good project requires good scalability. if you write all the logical relationships and configuration information into the code, the scalability of the program will deteriorate. to solve this problem, xml allows you to schedule the entire project (spring)

Xml is also used for data storage, but it is rarely used. most of them are used to store configuration information.

Different xml files play different roles: for example, the configuration files in the web project play the role of configuration paths and redirect requests. The configuration file of hibernate serves to configure the connected database and related attributes, and map the object classes and relational databases. the configuration file of spring serves to configure the instantiation of javabean and the integration framework. Some xml files store some data for the program to read.
In fact, the configuration file is equivalent to a small database for storing data. you can read the configuration file using some jar packages such as dom4j to read and write the configuration file, there are also cross-language media !!

The above is a detailed description of the role of XML in JAVA projects. For more information, see other related articles in the first PHP community!

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.