Maven (III): maven project structure and running mechanism, and maven Running Mechanism
In the previous article, we talked about how to create a maven project. Now we can go back to that project.
Project Structure
Src/main/java: java code directory
Src/main/resources: Resource Directory, such as spring. xml file and properties Parameter
The contents of the java and resources directories are compiled to the classpath directory, which is the same as the src directory of traditional projects. The contents are divided into multiple directories to facilitate resource management during development.
Libraries: by default, only jre and maven are available. If the tomcat library is not introduced, our project should be able to run in all web servers, not just tomcat.
Webapp: This is the WebContent directory of traditional projects.
Web-resources: the function is unknown and can be ignored.
Src: full structure of the src root directory
Target: Maven output directory, which is the running mechanism of maven projects. See
Default temporary directory of tomcat: eclipse workspace \. metadata \. plugins \ org. eclipse. wst. server. core \ tmp0
Execute the project -- cleanup: the java file will be compiled into a class and output to the target directory (maven update will execute cleanup by default)
When you run tomcat in eclipse for the first time after cleaning, the target will be published to the tomcat temporary directory. If the target lacks class, a target error will be reported.
Run tomcat for the second time and later: there will be a local cache and will not be copied from the target.
Browser access: requests a temporary tomcat directory. If an error is reported, the temporary tomcat directory is incorrect.
Add/modify/delete a java file: the class is automatically compiled and updated to the target (the class file is not displayed in the project view)
In the above process, if an accident occurs or the cache problem cannot be solved, you can remove the target and tomcat temporary directories, and then execute maven update and project-clean up. If not, restart the system.
Pom. xml:This is the maven configuration file, which is placed in the project root directory. eclipse uses this file to determine whether it is a maven project. The next article will explain it in detail.