The difference between classpath: and classpath*:

First classpath refers to the classes directory under the WEB-INF folder

Explain the meaning of classes:
1. Store various resource configuration files eg.init.properties log4j.properties struts.xml
2. Store template files eg.actionerror.ftl
3. Store class files corresponding to the src directory compilation file
summary during project development : This is an entry for locating resources

If you know that there is a saying in the development process: convention is greater than configuration, then maybe you will change your mind

For the second question,
this involves the issue of file access priority under lib and classes:
the impact of lib>classes on performance should not be in this category

The difference between classpath and classpath*:
classpath: will only look for files in your class path;
classpath*: not only include the class path, but also the jar file (class path) for search.

Java code collection code

Or refer to files in its subdirectories, such as
Java code collection code

The use of classpath : When there are multiple classpath paths in the project, and files under multiple classpath paths (mostly not encountered in this case) are loaded at the same time, it will play a role. If it is not added , it means that only the first one is loaded. classpath path, code snippet:
Java code collection code
: context/conf/controller*.xml

In addition:
" /" means any directory;
"
/applicationContext-.xml" means any XML file starting with "applicationContext-" in any directory

. After the program is deployed to tomcat, the configuration file in the src directory will be automatically copied to the application's WEB-INF/classes directory like the class file. The difference between classpath: and classpath : is that,

The former will only be loaded from the first classpath, while the
latter will be loaded from all classpaths

If the resource to be loaded is
not in the path of the current ClassLoader, it cannot be found with the classpath: prefix.
In this case, you need to use the classpath*: prefix

If there are resources with the same name in multiple classpaths, all of them need to be loaded,
then using classpath: will only load the first one. In this case, you also need to use the classpath*: prefix

Note:
Using classpath : You need to traverse all classpaths, so the loading speed is very slow. Therefore, when planning, you should plan the path where the resource files are located as much as possible, and try to avoid using classpath .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324824124&siteId=291194637