Applicationcontext.xml where the configuration file is stored

Source: Internet
Author: User

Web. XML classpath: And classpath*: What's the difference? Classpath: Only look for files in your class path; Classpath*: Includes not only the class path, but also the jar file (the class path) to find. Storage location: 1:SRC Below you need to define the following in Web. XML:<context-param><param-name>contextconfiglocation</param-name> <param-value>classpath:applicationContext.xml</param-value></context-param> 2:web-inf below you need to define the following in Web. XML:<context-param><param-name>contextconfiglocation</param-name>< param-value>web-inf/applicationcontext*.xml</param-value></context-param>web.xml How to configure Spring by Contextconfiglocation SSI Framework configuration file path problem: Struts2 1 +n path: src+src (configurable) Name: Struts.xml + N spring 1 paths: src name Applicationcontext.xmlibatis: 1 +n paths: src+src (configurable) Name: Sqlmapconfig.xml + N after deploying to Tomcat, the configuration file under the SRC directory will be the same as the class file. Auto Copy to the app's classes directory when the spring configuration file is started, the applicationcontext.xml in the Web-info directory is loaded, and the runtime uses web-info/ Applicationcontext.xml in the classes directory. Configure Web. XML to make these 2 paths consistent: <context-param> <param-name>contextConfigLocation</param-name> <paraM-value>/web-inf/classes/applicationcontext.xml</param-value> </context-param> loading of multiple configuration files < context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath*:conf/ Spring/applicationcontext_core*.xml, Classpath*:conf/spring/applicationcontext_dict*.xml, classpath*:conf/spring /applicationcontext_hibernate.xml, Classpath*:conf/spring/applicationcontext_staff*.xml, classpath*:conf/spring/ Applicationcontext_security.xml Classpath*:conf/spring/applicationcontext_modules*.xml classpath*:conf/spring/ Applicationcontext_cti*.xml Classpath*:conf/spring/applicationcontext_apm*.xml </param-value> </ The context-param> contextconfiglocation parameter defines the Spring configuration file to be loaded. The first spring-related configuration file must start with "applicationcontext-", conforming to the idea that the contract is better than the configuration, which is much better in terms of efficiency and error rates. It is also best to put all the spring configuration files in a unified directory, if the project is large, you can also sub-module to build the directory. The program does not look very messy. The configuration in Web. XML is as follows: Code <context-param> < param-name>contextconfiglocation</param-name> < param-value>classpath*:* */applicationcontext-*.xml</param-value> </context-param> "**/" means any directory; "**/applicationcontext-*.xml" Represents an XML file that begins with "applicationcontext-" in any directory. You can modify it yourself as needed. It's a good idea to put all the spring profiles in a single, unified directory, such as: <!--Spring configuration-<context-param> <param-name> Contextconfiglocation</param-name> <param-value>classpath:/spring/applicationcontext-*.xml</  Param-value> </context-param>

Applicationcontext.xml where the configuration file is stored

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.