Maven_Basic_hehe.employment.over.24.1

24.1 Maven_Overview

24.1.1 What is Maven

  • The correct pronunciation of Maven is [ˈmevən], not "horse plague" or other plagues. Maven is a colloquial term in the United States, which means expert and expert.
  • A more formal definition of Maven says this:Maven is a project management tool, it contains a project object model (POM: Project Object Model), a set of standard collections, a project lifecycle (Project Lifecycle), a dependency management system (Dependency Management System), and used to run Define the logic of the plugin goal in the life cycle phase

24.1.2 What problems can Maven solve

  • It can be explained in a more popular way. We know that project development is more than just writing code, it will be accompanied by various essential things to do during the period. Here are a few feelings:
    • 1. We need to quote various jar packages, especially for relatively large projects. There are often dozens or even hundreds of jar packages. Every time a kind of jar package is used, we need to manually import the project directory, and we often encounter Various jar package conflicts and version conflicts that make people crazy.
    • 2. We have worked so hard to write the Java file, but an idiot computer that only understands 0 and 1 can't read it at all and needs to compile it into binary bytecode. Anyway, this work can be done for us by various integrated development tools. Eclipse, IDEA, etc. can compile the code on the fly. Of course, if you think that your life is long, why not be extravagant, you can also use Notepad to type the code, and then use the javac command to compile one by one, tease the computer.
    • 3. There is no code without bugs in the world. Computers like bugs just like people always like beautiful and handsome guys. In order to pursue beauty and reduce bugs, after writing the code, we have to write some unit tests, and then run them one by one to verify the quality of the code.
    • 4. No matter how elegant the code is, it will be sold. Later, we need to integrate the code with various configuration files and resources, and finalize and package them. If it is a web project, we also need to publish it to the server for people to ravage.

24.2 Maven_Dependency Management Concept

24.2.1 Examples of Maven Advantages

  • Previously, we used the Web phase project. To be able to run the project, some jar packages that the project depends on must be added to the project, otherwise the project will not run. Imagine if there are ten projects with the same architecture, then we need to copy this jar package to ten different projects. Let's take a look at the project size of a CRM project.
  • The CRM projects built using traditional Web projects are as follows:
    Insert picture description here
  • The main reason is that the above WEB program needs to be run, and we have to copy the Jar package needed for the project to the project directory, which results in a very large project.
  • For the same project, if we use the Maven project to build, we will find that the overall project size will be much smaller. As shown below:
    Insert picture description here

24.2.2 Maven's dependency management

  • A core feature of Maven is dependency management. When we involve multi-module projects (including hundreds of modules or sub-projects), managing dependencies becomes a difficult task. Maven demonstrates its high degree of control in handling this situation.
  • In traditional WEB projects, we have to copy the jar packages that the project depends on to the project, which causes the project to become very large. So how does the maven project make the project less?
  • analyse as below:
    Insert picture description here
  • Through analysis, it is found that the jar package is not directly imported into the project in the maven project, but by adding the coordinates of the required jar package in the pom.xml file, which avoids the direct import of the jar, which is used when needed When jar package, just look for the pom.xml file, and then use
    the coordinates in the pom.xml file to find these jar packages according to the coordinates in a "repository for storing jar packages" (maven warehouse), and then add these Take the jar package to run.
  • Icon:
    Insert picture description here

24.3 Maven_ the concept of one-click build

  • Our projects often have to go through a series of processes such as compilation, testing, running, packaging, installation, and deployment. What is build?
    • It means that the entire process of the project from compiling, testing, running, packaging, installing, and deploying is handed over to maven for management. This process is called build.
  • One-click build
    • Refers to the entire build process, and the entire work can be easily completed with a single command of maven.
  • The Maven standardized build process is as follows:
    Insert picture description here

Guess you like

Origin blog.csdn.net/qq_44686266/article/details/113854350