Classpathxmlapplicationcontext and Filesystemxmlapplicationcontext path issues

Source: Internet
Author: User

Classpathxmlapplicationcontext Problems in 1.Spring

Classpathxmlapplicationcontext is loading the corresponding XML file from the Classpath class load path.

(1) Generally use classpath path, prefix can be added without adding,

Example: New Classpathxmlapplicationcontext ("Classpath:conf/core/train-servlet.xml")

(2) You can also use absolute path, plus file: Absolute path, generally not recommended absolute path

2. Filesystemxmlapplicationcontext:

(1) using the path of the file system, the default specifies the root path of the project, SRC

Example: New Filesystemxmlapplicationcontext ("Src/conf/core/train-servlet.xml")

(2) You can also use the classpath path so that you can read the relative path below the classpath,

Example: New Filesystemxmlapplicationcontext ("Classpath:conf/core/train-servlet.xml")

(3) No need to add File: prefix denotes absolute path, do not advocate use

1. No drive letter is the project work path, that is, the root directory of the project; Src

2. A drive symbol indicates the absolute path of the file. D:\test\ Error Problem:

Noclassdeffounderror The reason is that the corresponding class is not found and the corresponding bean in the Spring.xml file is configured incorrectly.

Classpathxmlapplicationcontext and Filesystemxmlapplicationcontext path issues

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.