Detailed explanation of class path in Spring

Simple explanation: Taking the ssm project as an example, the classpath points to the location of the classes after the war package is created. The classes folder contains the java files of the original project and the contents of the resources folder.

1.Web project engineering structure

Insert image description here

2. Packing

The java and resources folders under src/main/ have been (compiled) packaged into the WEB-INF/classes/ directory of the production package; while the original views (jsp) and web.xml under WEB-INF are still in WEB -INF below. At the same time, the dependencies introduced by maven are placed under WEB-INF/lib/. Finally, the compiled class files and resource files are placed in the classes directory.
Before packing:
Insert image description here
After packing:
Insert image description here

3.The difference between classpath and classpath*

In classpath:dev/spring-mvc.xml, classpath refers to the path to the WEB-INF/classes/ directory. Using the classpath: prefix can only represent one file.

classpath*: /mapper/ Mapper.xml, using classpath : This prefix can represent multiple matching files; /mapper/*Mapper.xml, double asterisk ** means in any directory, that is to say, in WEB- Directories at any level under INF/classes/ will be found as resource files as long as they match the following file paths.

Guess you like

Origin blog.csdn.net/hansome_hong/article/details/124267485