Briefly talk about Maven and its configuration

Maven

Introduce

In the development process of JavaWeb, we need to use a large number of jar packages to help us realize various business functions, but manual import is extremely cumbersome, so is there anything that can realize automatic import of these jar packages and free our hands ? At this time a tool called Maven appeared.

Overview

Maven is a pure Java development open source project under Apache; it is a project management tool that can build and depend on Java projects; Maven can also be used to build and manage projects written in other languages, such as C#.

Core idea: Conventions are greater than configuration . Because many Java-written specifications are constrained in Maven, the conventions must be strictly followed when using Maven.

Installation configuration

download

Insert picture description here

  • Unzip and get the following file

Insert picture description here

Configure environment variables

Add the following configuration to the system environment variables:

  • Variable name: M2_HOME Variable value: bin directory under maven
  • Variable name: MAVEN_HOME Variable value: maven root directory
  • Add under path: %MAVEN_HOME%\bin

Then execute the mvn -v command under cmd to see if the configuration is successful:

Insert picture description here

Configure Alibaba Cloud image

Since the Maven remote warehouse is abroad and the domestic IP access speed is limited, the Alibaba Cloud domestic mirror warehouse is used.

  • In the conf directory, find the settings.xml configuration file

  • In <mirrors> Fill the tag follows:

     <mirror>
         <id>nexus-aliyun</id>
         <mirrorOf>*,!jeecg,!jeecg-snapshots</mirrorOf>
         <name>Nexus aliyun</name>
         <url>http://maven.aliyun.com/nexus/content/groups/public</url> 
     </mirror>
    

Configure local warehouse

  • Create a new folder maven_warehouse in the maven directory

Insert picture description here

  • Find the following code in the settings.xml configuration file:

    <localRepository>/path/to/local/repo</localRepository>
    
    • Copy it outside the comment, and edit the content inside to be the directory address you just created.

Guess you like

Origin blog.csdn.net/ITMuscle/article/details/111932649