Storage location of applicationcontext. xml configuration file

Source: Internet
Author: User
In web. XML, what is the difference between classpath: And classpath? Classpath: searches for files only in your class path. classpath *: not only contains the class path, but also contains the JAR file (class path. storage location: 1: SRC needs to be stored in web. <context-param> <param-Name> contextconfiglocation </param-Name> <param-value> classpath: applicationcontext. XML </param-value> </context-param> 2: The WEB-INF needs to be in the web. the XML definition is as follows: <context-param> <param-Name> contextconfiglocation </param-Name> <param-value> WEB-INF/applicationcontext *. XML </param-value> </context-P Aram> Web. XML uses contextconfiglocation to configure spring. ssi framework configuration file path problem: 1 + N paths of struts2: SRC + SRC (configurable) Name: struts. XML + N spring: SRC name: applicationcontext. one + N xmlibatis paths: SRC + SRC (configurable) Name: sqlmapconfig. after XML + N is deployed to Tomcat, the configuration file under the src directory will be the same as the class file, automatically copy to the spring configuration file under the classes directory of the application at startup, the applicationcontext under the web-info directory is loaded. XML, which is used in the applicationcontext under the web-info/classes directory. XML. Configure web. XML to make the two paths consistent: <context-param> <param-Name> contextconfiglocation </param-Name> <param-value>/WEB-INF/classes/applicationcontext. XML </param-value> </context-param> load 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/applicationcontex T_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 *. the XML </param-value> </context-param> contextconfiglocation parameter defines the spring configuration file to be loaded. First, the spring-related configuration file must start with "applicationcontext-" and comply with the agreed idea that is better than the configuration, which is much more efficient and error-prone. It is also best to put all the spring configuration files in a unified directory. If the project is too large, you can create a directory under this directory by module. In this way, the program will not look messy. In the web. the configuration in XML is as follows: XML Code <context-param> <param-Name> contextconfiglocation </param-Name> <param-value> classpath *: **/applicationcontext -*. XML </param-value> </context-param> "**/" indicates any directory; "**/applicationcontext -*. XML indicates the XML file starting with "applicationcontext-" in any directory. You can modify it as needed. It is best to put all spring configuration files in a unified directory, such as: <! -- Spring configuration --> <context-param> <param-Name> contextconfiglocation </param-Name> <param-value> classpath:/spring/applicationcontext -*. XML </param-value> </context-param>

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.