Detailed explanation of how IntelliJ IDEA integrates Maven graphic tutorials

Maven

1. Brief introduction of Maven

Maven is a construction tool, service and construction. After using Maven to configure the project, enter a simple command, such as: mvn clean install, Maven will help us deal with those tedious tasks. Maven is cross-platform. Maven maximizes the
elimination
of Repetition of construction.
Maven can help us standardize the construction process. All projects are simple and consistent, which simplifies learning costs.
In short, Maven, as a construction tool, not only helps us automate construction, but also abstracts the construction process and provides construction task implementation .It is cross-platform and provides a consistent operation interface externally, which is enough to make him an excellent and popular construction tool. But
Maven is not only a construction tool, but also a dependency management tool and project information management tool. He also provides a central Warehouse, which can help us download components automatically.
Using Maven can also enjoy an additional benefit, that is, Maven has established rules for project directory structure, test case naming methods, etc. As long as these mature rules are followed, users can When switching, additional learning costs are eliminated. It can be said that convention is better than configuration (Convention Over Configuration)

2. Install the Maven environment

2.1 Download Maven

The official download address of the latest version of Maven: Click here

insert image description here

2.2 Unzip Maven

Find a local path to store Maven files
insert image description here

2.3 Configure Maven's environment

Maven environment variable configuration can refer to JDK environment variable configuration.

1. First, right-click on the computer->Properties->Advanced System Settings->Environment Variables, in the system environment variables, the new variable name variable value is the MAVEN_HOMEdecompressed maven path (note that it must be the upper level directory of the bin directory), in Here is G:\Maven\apache-maven-3.8.4
insert image description here
2. At the end of the system environment variable Path, add %MAVEN_HOME%\bin, pay attention to separate with the previous content with a semicolon
insert image description here

2.4 Test whether the Maven environment is normal

Open cmd and execute mvn -versionthe command, the result as shown in the figure indicates that the environment configuration is correct
insert image description here

3. Integrate Maven into IntelliJ IDEA

  1. Create a new directory in the maven directory of the G drive MavenRepository(the name can be customized, as a local warehouse, and future jar packages will be automatically downloaded here), then open and enter the decompressed package conf目录, and find settings.xmlthe core configuration file
    insert image description here
  2. Find the location of the localRepository label in the file, configure the local warehouse address, and modify the configuration as follows:
    insert image description here
  3. Find the location in the file mirrors标签and configure the domestic mirror mirrors标签inside . Here we use the Alibaba Cloud mirror (the default is foreign, the speed is very slow, of course you can also configure multiple mirrors) and the central warehouse 1 as a backup. The configuration is as follows:
<!--阿里云central仓和jcenter仓的聚合仓-->
<mirror>
  <id>aliyunmaven</id>
  <mirrorOf>*</mirrorOf>
  <name>阿里云公共仓库</name>
  <url>https://maven.aliyun.com/repository/public</url>
</mirror>

insert image description here
Other mirror source recommendations:

<!--中央仓库1-->
<mirror>
    <id>central</id>
    <name>Maven Repository Switchboard</name>
    <url>https://repo1.maven.org/maven2/</url>
    <mirrorOf>central</mirrorOf>
</mirror>
<!-- 推荐1—中央仓库2 -->
<mirror>
    <id>repo2</id>
    <mirrorOf>central</mirrorOf>
    <name>Human Readable Name for this Mirror.</name>
    <url>https://repo2.maven.org/maven2/</url>
</mirror>
<!-- 推荐2-->
<mirror>  
    <id>activiti-repos2</id>  
    <name>Activiti Repository 2</name>  
    <url>https://app.camunda.com/nexus/content/groups/public</url>  
</mirror>  
<!-- 推荐3-->
<mirror>  
    <id>activiti-repos</id>  
    <name>Activiti Repository</name>  
    <url>https://maven.alfresco.com/nexus/content/groups/public</url>  
</mirror>  
  1. Copy and paste the maven configuration file settings.xml to the C:\Users\Administrator.m2 directory, otherwise the configuration may not take effect.

Note: 1. The Administrator here refers to your current computer user name.
2. Generally speaking, you can directly configure the settings.xml under the compressed package config. It is safer to configure it in .m2 here. If you just use settings.xml under config, then when configuring in IDEA,
check Override at the User settings file and redesignate it as settings.xml under config.
3. If there is no .m2 folder under C:\Users\Administrator, you can create a new one A .m2 folder, or use the default configuration when maven's settings.xml does not configure localRepository, execute the following command in cmd: mvn help:system and then ctrl+c to terminate
, and then go to C:\Users\Administrator You will find that there is a .m2 folder

4. Deployment Intellij IDEA

  1. Open IDEA File > Settings > 搜索Maven, click Maven, set the Maven Home directory and User Settings as shown in the figure, the local warehouse will automatically detect the previously configured directory, and finallyApply --> OK
    insert image description here

5. This completes the configuration!

Guess you like

Origin blog.csdn.net/Python_BT/article/details/129325086