Detailed explanation of Maven commands

Detailed explanation of Maven commands

Maven command?

1.clean

clean is the cleanup command of the maven project. Executing clean will delete all contents in the target directory and its directory

Compile

compile is the compile command of the maven project. Its function is to compile the java source file under src / main / java into a class file and output it to the classes directory under the target.

cmd enters the command state, execute mvn compile,

 

Check the target directory under classes, the class file has been generated, and the compilation is complete

 

2.test

test is the test command mvn test of the maven project, which will execute the unit test class under src / test / java.

The cmd executes mvn test to execute the unit test class under src / test / java. The following figure shows the test results. One test case was run and all succeeded.

It will compile the java source code, and also compile the java source code in the test directory, and then run the test method in the test class

3.package

The package is the packaging command of the maven project. For the java project, the package is converted into a jar package, and for the web project, it is labeled as a war package.

Execute mvn package in the project directory

4.Install

install is the installation command of maven project, execute install to publish maven into jar package or war package and publish it to local warehouse

 

From the running results, we can see:

When the following command is executed, the previous operation process will also be automatically executed

  1. Three sets of life cycles

Maven divides the project construction process into three sets of independent life cycles. Please note that here are "three sets" and "independent". The three sets of life cycles are:

 

  1. Clean Lifecycle: Do some clean-up work before the actual build.
  2. Default Lifecycle: The core part of the build: compile, test, package, deploy, etc.
  3. Site Lifecycle: Generate project reports, sites, and publishing sites.

 

Each stage has a corresponding command, and there are corresponding plug-ins to support the operation of the command.

 

Note: The instructions within the same instruction cycle, when the following commands are executed, the previous commands will be automatically executed.

When adding the coordinates of the jar package, you can also specify the scope of the jar package in the future

 

 

 

 

 

 

 

 

Published 13 original articles · Like 3 · Visits 4975

Guess you like

Origin blog.csdn.net/u010919402/article/details/105561388