Article From:

MavenIt is an open source project management tool developed in pure Java based on the concept of Project Object Model (POM). Mainly used to manage Java projects, dependency management (jar package management, can automatically analyze the dependency packages needed by the project, and download them to Maven warehouse) and project construction (Project packaging and deployment. In addition, it can be developed in blocks to improve the efficiency of development.

  This article will start from the following three aspects:


  2、MavenInstallation configuration

  3、IDEAConfigure Maven

QQFigure 2: 20181031143508 uuuuuuuuuuuu

  1、MavenWhy use Maven

  (1)Create projects, automatically associate and download dependent jar packages.

  (2)Upgrade the version of the framework. Upgrade the version of a framework, but do not know which jars associated with it need to follow the upgrade, and upgrade to which version.

  (3)Automatic deployment. With Maven, you can automatically deploy the project to a remote server with just one command.

  (4)Project compilation, packaging and export. This can be done by any IDE, so if Maven is to do this, the possible scenario is to do it in an environment without an IDE, such as in a server-side Linux environment.

  2、MavenInstallation configuration

  1、Download maven’s address:

  2、Unzip, and then add the following information to “My Computer” – – “Properties” – – “Advanced System Settings” – – “Environment Variables”:

  a、Installation folder for Maven with the value of new variable MAVEN_HOME

  b、Add:% MAVEN_HOME%\bin to PATH variable

  3、Verify that the configuration is successful, open CMD and enter: mvn-version

  MavenConfiguration file (settings. xml) specification

  1.localRepository:Set up local warehouse:


  2.pluginGroups:Plug-in combination


  4.serversServer (where username and password are the username and password of private service, followed by configuration of private service instructions)











  5.mirrors:Mirror path

  <!– Alibaba mirror –>



  <name>aliyun maven</name>




  6.profiles:Server configuration

  <!–Server Configuration – & gt;

















  <!– Plug-in warehouse, the operation of Maven depends on plug-ins, also need to download plug-ins from private service – & gt;


  <!– The ID of plug-in repository does not allow duplication, and if the configuration is repeated, it will cover the front – & gt;


  <name>Public Repositories</name>





  <!– javaCompiler plug-in, compiler version of JDK – & gt;













  7.activeProfiles:Activate private clothes




  MavenWarehouse description

  Warehouse for storing jar (3 warehouses)

  1.Local Warehouse: Stored on local disk, default on System Disk C disk username/.m2/xx

  Change the local repository of the local repository through settings. XML

  2.Remote Warehouse: Usually domestic mirrors or companies build their own private clothes. Usually Nexus is used.

  OBJECTIVE: To accelerate download speed

  3.Maven(Central) Warehouse: The jar package warehouse maintained by the Maven team at

  Use this to check POM:

  Retrieval order: first retrieve the local warehouse, then retrieve the remote warehouse, and finally retrieve the central warehouse

  MavenManage project cycle

  1. Clean:Cleaning up before project construction

  2. Default: Core Life Cycle Core Processes: Compilation, Running, Packaging, etc.

  3. Site:Publishing sites, generating reports, etc.

  3、IDEAConfigure Maven

  IDEAMaven is integrated internally, or can be configured to install Maven on your own.

  File —-> Settings —-> Find Maven and configure Maven home directory

Picture 2

  Create Maven project

  File —-> New —-> Project —-> Maven

  Check Create from archetype

  Select maven-archetype-webapp

  Click Next

Picture 3

  Enter GroupId, ArtifactId and click Next

Picture 4

  Select version of Maven

Picture 5

  Enter the project name and directory, and click Finish

Picture 6

  After creating the project, click the Import Changes button to download the required jar packages and plug-ins

Picture 7

  MavenProject description

  src/main/java:The. java file that stores the project

  src/main/resources:Deposit project resource files. How to Spring, Hibernate Profile

  src/test/java:Store all test. Java files, such as Junit test classes

  pom.xml(mavenProject Core Profile)

  pom.xmlDefault Content Introduction:

  <!– mavenThe version number of the middle model – & gt;


  <!– Company name or organization name or personal name – & gt;


  <!–The name of the project is –>


  <!– Version number –>


  <!– Packaging: Project type

  POM:MAVENProjects, often used in inheritance and aggregation

  JAR:JAVASEProjects, no web pages, nothing to do with the server

  WAR:JAVAEEProject, it’s nothing to do with the server – & gt;


  MavenEngineering add dependency

  Recommended website:



  <!– –>







  Add the POM file content description to the project (switch pom. XML to the Dependencies directory):


  Value Description:


  Scope:Declare the lifetime of the jar package

  Value Description:

  1、provided:Requirements for compilation and testing

  2、compile:Compile, test, run, package requirements

  3、runtime:Test, run, package requirements


  5、system:When compiling and testing, you need to display references, and Maven will not retrieve them.

Leave a Reply

Your email address will not be published. Required fields are marked *