Quickly build a project through MAVEN (1)

                            Quickly build a project through MAVEN

What is MAVEN?

MAVEN is a software management tool. All configuration information in a Maven project is defined in a file called POM.xml, through which Maven can manage the project, including compiling, building, testing, publishing, reporting, and more. It is also by far the most popular project management tool.

The difference between Maven and ant

MAVEN is a project management tool, ANT is just a project building tool. This is essential. ANT is generally only used for compiling, building, testing, etc. But the function of maven is much higher than that of ant. In addition to the above functions, maven has the following differences:

1. Use POM to manage projects

In ant, you can also configure project information through build. But the functionality of submodules proposed by maven. Ant is not clearly defined

2. Unify the placement of the source code. Ant allows users to modify the location of the source code themselves. Ant is more flexible, maven has a unified standard

3. Built-in dependency management and Repository to achieve dependency management and unified storage. Ant can also do it through plugins, but plugins can't manage dependencies between jars well

4. Built-in software build life cycle. The life cycle of ANT can be defined by itself, which is more flexible, and maven is more standardized.

In general, maven is more like a specification. If users manage projects according to maven's specifications, the complexity of the code can be greatly reduced.

Use of Maven

I will not go into details about the specific download, there are many examples on the Internet. I will skip the steps of how to download here. I will use SpringSource Tool Suite (which can be regarded as the spring version of eclipse, which has many good functions combined with spring) to introduce how to quickly build a project

1. First build a maven project.



 

2. Select the corresponding project build mode:

This step is more complicated, and it is recommended to choose to build a simple project



 

If you must build your own, you can cancel

Then go to the next page to select the corresponding build method


 

Beginners recommend simple build mode

 

3. Build the project

By default, we use the simple build mode to enter the following page

 


 

Different project build mode pages are different, but the above elements are basically the same

Group Id: Organization ID

Artifact Id: Project name.

The package structure of the proposed project is also prefixed with Group Id + Artifact Id

Version: The version number snapshot represents an unreleased version

Packaging: Project Type Here I want to publish a WEB project so choose war


 

In this way, the project is clearly displayed in front of the user.

Finally, look at the generated pom.xml



 

OK project is simple to build

4. Publish the project 

Right-click on pom.xml and select run as to use maven to build the project

Here we choose MAVEN INSTALL (for the specific build life cycle, please refer to the maven documentation)



 

Building the project failed. . . what happened? ?

In fact, the error log below clearly tells us the reason:

Missing web.xml file.

OK this time we put the web.xml file under the web-inf directory

 

Then continue to execute, this time the release project is successful

Generated under the target directory

Maven-demo-0.0.1-snapshot.war

 

The above is the construction of the simplest maven project

 

In the next article, we will talk about how to configure the dependency library and start the project

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326619289&siteId=291194637