In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces what the classpath in java points to, the article is very detailed, has a certain reference value, interested friends must read it!
Today, I saw that classpath was used in many places in the project, and I didn't know where the calsspath pointed to, so I took a look at Baidu on the Internet!
To put it simply, the meaning of the above picture is that classpath can only represent files under the lib directory and WEB-inf/classes path, and files under the src path that calsspath cannot represent.
But from the point of view of the project structure, the configuration file is generally not placed under WEB-INF, and the classes path is not seen, and the lib directory depends on the jar package. I feel cold at this time. And tested it, created the lib and classes folders under the WEB-INF path
The test results are also obvious that the files under the classes and lib paths under WEB-INF cannot be accessed, and an error has been reported.
However, I have a thought, no, ah, it is clear that the project can use classpath to introduce configuration files, so how on earth is introduced?
From the first and second pictures, I used classpath to access the configuration file in the main/resources file under the src path.
Open the compiled project and find that there is a file named .classpath in the project file.
For an introduction of specific classpath files, please refer to the following blog
.classpath file detailed explanation
Classpath file is used to record all information about the project's compilation environment, including: source file path, compiled class file storage path, dependent jar package path, running container information, dependent external project and other information. If the file is deleted, eclipse cannot identify the project as a normal java project, only as a normal folder, which will not work properly.
The specific location of the source file (kind= "src")
Running system environment (kind= "con")
Specific location information of the library of the project (kind= "lib")
In each lib's XML child node, there is additional configuration information about it (such as the "javadoc_location" I configured)
Output directory of the project (kind= "output")
Generally speaking, this file is to configure the running environment of the whole project.
It is clear that the classpath is worth the file specified (kind= "src"), and you can see that the setting of (kind= "src") does not include the WEB-INF file. At this point we want to verify that the WEB-INF file is accessed by classpath is related to this setting.
First of all, we put the applicationContext.xml file under the WEB-INF path, and the contents of the .classpath file are shown below to start the project.
Open the original file of the project and find that applicationContext.xml does not appear.
At this point, we add to the .classpath file
Classpathentry kind= "src" path= "WebContent/WEB-INF" /
Start the project again
Open the original path of the project and find that applicationcontext.xml appears under WebContent/WEB-INF
This can be summarized as follows:
1, the file generated at compile time. The type of kind= "src" in classpath is the classpath path, which can be referenced by classpath:xxx in the project. You can also add and expand the scope of classpath manually, that is to say, if you want to know where classpath can reference files, click .classpath to see kind= "src".
2. The files under the bulid/classes/ under the compiled project are all files under the classpath path, which can be obtained through the classpath: method. (classes: refers to compiled files)
3. The sentence "src is not classpath, but WEB-INF/classes,lib is classpath" will also be wrong. This is what you see when writing a project. The real classpath is the path where the compiled file is stored, and the default is bulid/classes/ (such as conclusion 2).
The above is all the content of the article "what does the classpath in java point to?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.