Maven (III): maven project structure and running mechanism, and maven Running Mechanism

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.