Maven tutorial 1: Eclipse builds a simple Maven project

Time:2021-3-3

About the new Maven project

Learn Maven for the first time, use eclipse + m2eclipse, and use Maven as a plug-in form. The purpose is to reduce the complexity of operating system installation of Maven and various problems in troubleshooting.

Select project type

File→New→Other→Maven Project

Maven tutorial 1: Eclipse builds a simple Maven project

Select workspace

Create a workspace for the project and check use default workspace.

Maven tutorial 1: Eclipse builds a simple Maven project

Select QuickStart project skeleton

Maven archetype QuickStart is selected as the project object skeleton by default.

Maven tutorial 1: Eclipse builds a simple Maven project

POM three element filling

  1. Fill in groupid, artifactid and version, which are the most important elements in POM!

  2. These three elements define the basic coordinates of a maven project. In maven, any jar, war and POM are distinguished by these basic coordinates.

  3. Groupid defines which group a project belongs to, which group is often associated with the company or organization where the project is located.

  4. Artifactid defines the unique ID of the current project in the group.

  5. Version sets the current version of the project. Snapshot is a snapshot, which means that the project is still under development and is an unstable version.

  6. The name element is not necessary, but it is recommended to declare a name for each POM, which is more user-friendly.

  7. Click Finish to generate the project automatically.

Maven tutorial 1: Eclipse builds a simple Maven project

Project structure

You can see the project structure and the POM.xml Has been generated automatically.

Maven tutorial 1: Eclipse builds a simple Maven project

summary

Without any actual java code, we can define the POM of a project, which reflects one of the advantages of Maven. It can make the project object model independent of the actual code to the greatest extent. We can call it decoupling or orthogonality. This largely avoids the interaction between Java code and POM code. For example, when a project needs to upgrade its version, it only needs to modify the POM without modifying the Java code; after the POM is stable, the daily java code development work basically does not involve the modification of the POM.

Recommended Today

Practice analysis of rust built-in trait: partialeq and EQ

Abstract:Rust uses traits in many places, from simple operator overloading to subtle features like send and sync. This article is shared from Huawei cloud community《Analysis of rust built-in trait: partialeq and EQ》Author: debugzhang Rust uses traits in many places, from simple operator overloading to subtle features like send and sync. Some traits can be automatically […]