Installation & Configuration Maven

First, the need to prepare

1. JDK

Check local JDK is installed successfully:

java -version

2.IntelliJ IDEA

3. Maven package

 

Second, download and install Maven

1. Download: https://maven.apache.org/download.cgi

 

 

 

 

 

2. Extract the files to: D: \ Program Files \ apache-maven-3.6.2

 

3. Open the optical properties of the system, environment variables added:

New environment variable MAVEN_HOME, assignment D: \ Program Files \ apache-maven-3.6.2

 

 

 

4. Edit environment variables Path, Append% MAVEN_HOME% \ bin \;

 

 

5. At this point, maven installation has been completed, we can check whether we installed the DOS command success:

mvn -v

 

 

Third, configure Maven local repository

1. D: New maven-repository folder \ Program Files \ apache-maven-3.6.2 \ directory, the directory as a maven of local libraries.

2. Open the D: \ Program Files \ apache-maven-3.6.2 \ conf \ settings.xml file, find the following line of code:

 

 

<localRepository>/path/to/local/repo</localRepository>

localRepository default node is commented out, it needs to move beyond the notes, then the value of the node to the directory D localRepository we created in 3.1: \ Program Files \ apache-maven-3.6.2 \ maven-repository .

 

 

3. localRepository node is used to configure a local warehouse, local warehouse in fact, played a buffer role, its default address is C: \ Users \ username \ .m2.

When we get the package from the jar maven in time, maven will first look in the local warehouse, if the local warehouse is returned; if not from the remote repository to obtain package and stored in a local library.

此外,我们在maven项目中运行mvn install,项目将会自动打包并安装到本地仓库中。

 

4. 运行一下DOS命令

mvn help:system

如果前面的配置成功,那么D:\Program Files\Apache\maven-repository会出现一些文件。

 

 

四、配置IntelliJ IDEA的Maven环境

1.打开File--->settings  进行maven配置

a.Maven home directory:本地安装maven路径    D:/Program Files/apache-maven-3.6.2

b.User settings file:settings.xml路径    D:\Program Files\apache-maven-3.6.2\conf\settings.xml

c.Local repository:本地仓库路径     D:\Program Files\apache-maven-3.6.2\maven-repository

 

Maven的安装和配置全部结束

 

五、创建Maven项目

1.打开File--->New--->Project    

 

 

2.选择Maven,在Project SDK下拉列表中选择需要的JDK版本

 

 

3.设置GroupID、ArtifactId、Project name【尽量保证ArtifactId和Project name一致】

4.右下角提示“maven projects need to be importd”   选择Import Changes

至此,一个项目创建好了。

Guess you like

Origin www.cnblogs.com/ohlala/p/11911054.html