Introduction to maven and its advantages
maven is a project construction and management tool, providing methods to help manage construction, documentation, reports, dependencies, scms, publishing, and distribution. It can easily compile code, manage dependency, manage binary libraries, etc. The advantage of maven is that it can standardize, automate, efficiently and powerfully scalable the project process. Maven itself and its plug-ins can also obtain code inspection reports, unit test coverage, achieve continuous integration, etc.
Maven Advantages:
1. Project automation compilation and deployment
2. Dependency management of project jar package
3. Project plug-in management
Maven is prototyped around the core concept of building a life cycle. The creation and deployment of the entire project revolve around the life cycle, and a life cycle consists of several life cycle stages.
Maven has three built-in default life cycles, namely default, clean and site.
The default lifecycle handles your project deployment, the clean lifecycle handles the cleaning of the project, and the site lifecycle handles the creation of site documents of your project.
Each of these builds' life cycles is a different list of the editing stages, where the build stage represents a phase defined in the life cycle.
For example, the life cycle of default includes the following stages (for a complete list of life cycle phases, see Lifecycle Reference):
validate - Verify that the project is correct, all necessary information are available, please visit
compile - compile the source code of the project
test - Compile source code with the appropriate unit testing framework. These tests should not require the code to be packaged or deployed
package - Package in compiled code and packaged in its distribution format, such as a JAR.
verify - Running the inspection of integrated test results to ensure quality standards are met
install - The package is installed locally into the local repository and used as a dependency for other projects
deploy - Complete build environment, copy the final package to the remote repository to share with other developers and projects
When the default lifecycle is default, Maven will first verify the project, then try to compile the source code, run those tests, encapsulated binary files (such as JARs), run integration tests against this package, verify integration tests, install verification packages to the local repository, and finally deploy the installed packages to the remote repository.
Commonly used maven command line:
mvn clean
Delete any generated output (such as class files or jar files)
mvn test
Run unit tests for the project
mvn install
Copy project artifacts to your local repository
mvn deploy
Copy project artifacts to remote repository
mvn site
Create a project document (such as a report or Javadoc).
mvn compile
Compilation
mvn validate
PS: Let's take a look at the commonly used commands of maven in Eclipse
Right-click the shortcut in a certain maven project, and then click Run As to discover several Maven commands:
Maven Build:
This command is used to compile Maven projects. After executing the command, the corresponding class file will be generated in the classes in the target folder.
Maven Clean:
Delete the target folder, that is, delete the generated package and class files.
Maven Test:
Automatically compile and run all test cases.
Maven install:
Publish and generate the corresponding package (in two forms: war and jar).