Path settings for spring configuration file Applicationcontext.xml

Source: Internet
Author: User

First look at the Web. XML configuration

1 <!--load Spring Container configuration -2     <Listener>3         <Listener-class>Org.springframework.web.context.ContextLoaderListener</Listener-class>4     </Listener>5 6     <!--set the path for the spring container to load all the configuration files -7     <Context-param>8         <Param-name>Contextconfiglocation</Param-name>9         <Param-value>Classpath*:config/applicationcontext.xml</Param-value>Ten     </Context-param>

Directory structure

When I configure this, no matter how to modify the path settings in Web. XML, start Tomcat and always fail to load applicationcontext.xml. After a painful ordeal, I found only files in the Webroot directory deployed to Tomcat. The Config folder is not deployed to Tomcat at all.

When I moved the config folder below the Webroot, I found it was still wrong and still couldn't load the Applicationcontext.xml file. It turns out that the "classpath*:config/applicationcontext.xml" file path was incorrectly written. After the "classpath*:" is removed, it can be loaded correctly.

Classpath: The resource file under the Classpath is loaded. All of the applicationcontext.xml are placed under SRC so that the configuration system can be loaded correctly. (Deployed to Tomcat after the Web-inf/classes folder)

Classpath*: The resource under the SRC file will be loaded, and all resources including the jar file will be loaded.

Path settings for spring configuration file Applicationcontext.xml

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.