First knowledge of Maven series (1): First knowledge of Maven and first knowledge of maven Series
What is Maven?
Maven mainly serves project construction, dependency management, and project information management based on the Java platform, and Maven is cross-platform. This means that both Windows and Linux or Mac are used, you can use the same command.
What is build?
The first thing that comes to the company every day is to pull the latest code and then perform a unit test (if it fails, you need to debug it with the relevant development colleagues and fix the wrong code ), then write your own unit test and write business code.
Looking back at our daily work, apart from coding, we spend a considerable amount of time on compilation, unit testing, document generation, packaging, deployment, and other tedious and inconspicuous tasks every day, this is the build.
So some people use the software method to make this series of work completely automated, so that the software can be built like a fully automated pipeline, just a simple command, all the cumbersome steps can be automatically completed, maven is such a tool that can help us automate the building process, from cleaning, compiling, testing to generating reports, to packaging and deployment.
Advantages of using Maven
Maven minimizes build duplication, abstracts build lifecycles, and provides implemented plug-ins for most build tasks. We no longer need to define the process, you don't even need to implement some tasks in these processes. The simplest example is testing. We do not need to tell Maven to test, but do not need to tell Maven how to run the test. We only need to follow the Maven conventions to compile the test case, these tests run automatically when we run the build.
Imagine Maven abstracts a complete model for building the lifecycle. This model draws on the advantages of a large number of other build scripts and build tools, and summarizes the actual needs of a large number of projects. If you follow this model, you can avoid many unnecessary errors, you can directly use a large number of mature Maven plug-ins to complete our tasks (many times we may not know that we are using Maven plug-ins ). In addition, if you have special requirements, you can easily implement your own plug-ins.
Maven also has an advantage that helps us standardize the building process. Before Maven, ten projects may have ten construction methods. After Maven is available, the build commands of all projects are simple and consistent, which greatly avoids unnecessary learning costs, it also facilitates the standardization of the project team.
In this open-source era, almost any Java application will borrow some third-party open-source class libraries, which can be introduced to the project through dependency. As dependencies increase, version inconsistencies, version conflicts, bloated dependencies, and other issues will emerge. It is boring to solve these problems manually. Fortunately, Maven provides an excellent solution, which provides a central repository to accurately locate each component (artifact) through a coordinate system ), that is, Maven can find any Java class library (such as a jar file) through a set of coordinates ). Maven introduced latitude and longitude to the world of this class library to make them orderly, so we can use it to manage dependencies in an orderly manner and easily solve complicated dependency problems.
Through some Maven derivative tools (such as Nexus), we can quickly search for them. As long as the coordinates are located, Maven can help us automatically download and save manual work.
Ps:
This article mainly introduces what Maven is and why Maven is recommended.