Today, when writing a demo on a book, I found that classpathxmlapplicationcontext (Stringg str) In this method is based on the SRC file as the starting address, and his directory is also in the SRC layer, No longer reaches the directory layer of the project file; str in the Filesystemxmlapplicationcontext (String str) method is based on the project layer as the starting address and root directory, and will no longer reach the other directory layer of the system. For example, when you want to use Classpathxmlapplicationcontext (String str), the. xml file is right below SRC, and if placed at the project directory level, it will be error- When you want to use Filesystemxmlapplicationcontext (String str), it is possible to compile the. xml file at the project directory layer (also known as the SRC sibling), and if you need to put it under SRC, you need to add a relative path part to Str. For example, str is "/src/beans.xml".
Beginner spring, about the Classpath,classpathxmlapplicationcontext () method