Java learning route sharing What is maven?

Maven is a project management and integration tool based on the Java platform, which abstracts the project development and management process into a project object model (POM). Developers only need to make some simple configurations, and Maven can automatically complete the compilation, testing, packaging, publishing, and deployment of the project.

Maven is written in the Java language, so it is as cross-platform as Java, which means that you can use the same commands to operate on Windows, Linux or Mac OS.

Maven uses a standard directory structure and default build life cycle, so developers can automatically complete the basic construction of the project in almost no time.

Maven can help developers complete the following tasks:

  • Build project
  • Generate documentation
  • Create report
  • Maintain dependencies
  • Software configuration management
  • release
  • deploy

All in all, Maven simplifies and standardizes the project build process. It seamlessly connects project compilation, document generation, report creation, publishing, deployment and other tasks into a complete life cycle.

Maven Goals

The main goal of Maven is to provide developers with:

  • A comprehensive model of your project that is reusable, maintainable and easy to understand
  • Tools and plugins for interacting with this model

Convention over configuration

Convention Over Configuration is one of the core concepts of Maven. Maven has stipulated the directory structure of the project, the naming method of test cases, etc. All projects managed by Maven must abide by these rules.

During the Maven project building process, a default project structure will be automatically created, and developers only need to place the corresponding files in the corresponding directory structure.

For example, the following table shows the default locations of project source code files, resource files, and other configuration in Maven projects.

document Table of contents
Java source code src/main/java
resource src/main/resources
Test source code src/test/java
Test resource files src/test/resources
Pack output file target
Compile output file target/classes

Features of Maven

Maven has the following features:

  1. Easy to set up.
  2. Usage is consistent across all projects.
  3. Dependencies can be managed and automatically updated.
  4. A large and growing resource library.
  5. Extensible, plug-ins can be easily written using Java or scripting languages.
  6. New features can be accessed immediately with little additional configuration.
  7. Model-based build: Maven has the ability to build any number of projects into predefined output types such as JAR, WAR.
  8. Project information adopts centralized metadata management: using the same metadata as the build process, Maven can generate a website and a PDF containing complete documentation.
  9. Release management and release releases: Maven can integrate with source code control systems (such as Git, SVN) and manage the release of projects.
  10. Backward compatibility: You can easily port projects from older versions of Maven to newer versions of Maven.
  11. Parallel build: It is able to analyze project dependencies and build work in parallel. Using this feature, you can improve performance by 20%-50%.
  12. Better error and complete reporting: Maven uses a better error reporting mechanism, which provides a link to the Maven Wiki page, where you will get a complete description of the error.

Maven installation and configuration

Maven is a Java-based project management tool, so the most basic requirement is to install JDK on your computer.

The system requirements for Maven are as follows:

JDK JDK 7.0 and above.
Memory There are no minimum requirements.
disk space The Maven installation itself takes approximately 10MB. In addition to this, additional disk space will be used for the local Maven repository. The size of the local repository will vary based on usage, but should be at least 500MB.
operating system There are no minimum requirements.

1.Java environment settings

Download and install JDK 7.0 and above from  the Java official website .

2. Download Maven

Download Maven from https://maven.apache.org/download.cgi . Here we take Maven 3.6.3 as an example. After the download is completed, just unzip it to the appropriate location. In this tutorial, we will unzip it to D:\apache-maven-3.6.3.

operating system Download version
Windows apache-maven-3.6.3-bin.zip
Linux apache-maven-3.6.3-bin.tar.gz
MacOS apache-maven-3.6.3-bin.tar.gz

3. Configure Maven environment variables

Right-click the "Computer" icon, select "Properties", then click "Advanced System Settings" and click "Environment Variables".

Create a new system variable MAVEN_HOME, the variable value is the Maven installation directory, as shown below

Edit the system variable Path and add the variable value: ;%MAVEN_HOME%\bin, as shown below

Executed in the command prompt mvn -version , the output result is as shown in the figure below, which proves that the Maven configuration is successful.

A complete set of Maven tutorials for Dark Horse Programmers, Maven project management from basic to advanced, Java project development must-know management tool Maven

Guess you like

Origin blog.csdn.net/Itmastergo/article/details/133124298