Detailed introduction to the role of XML in JAVA projects

黄舟
Release: 2017-03-30 14:21:31
Original
1920 people have browsed it

In java projects, xml files are generally used to store some configuration information
General programming, most of them are used to store configuration information. Take JDBC as an example, you can Write the database connection string to xml. If you want to modify the data source, you only need to change the xml. There is no need to recompile the java file. Moreover, these configuration information are put together, and other people can It is much more convenient when reading the code you wrote. In addition to configuration information, you can also write some corresponding relationships in xml in
framework, which is actually a kind of configuration information. Take struts as an example, The xml configuration is the relationship between the page URL and the background java class (action). When configuring and modifying, you only need to change an xml file. There is no need to search for the 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 needs to be well scalable If all logical relationships and configuration information are written into the code, the scalability of the program will be poor. In order to solve this problem, xml can schedule the entire project (spring)

There is also the use of xml as data storage, but it is rarely used. Most of it is used to store configuration information

Different xmls play different roles: for example, configuration files## in web projects #Plays the role of configuring paths and redirecting requests. The hibernate configuration file plays the role of configuring the connection database and related attributes and mapping the entity class and the relational database . The spring configuration file plays the role of Configure the instantiation of javabeans and the role of the integration framework. There are also some xml files that store some data for the program to read. In fact, in the final analysis, the configuration file is equivalent to a small database for storing data. Using dom4j and other jar packages that read and write configuration files can read the configuration files, and it can also be used as a cross-language medium! !

The above is the detailed content of Detailed introduction to the role of XML in JAVA projects. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!