第一步:下载maven(本教程安装的是3.8.4版本)
方法1:官网下载
Maven – Download Apache Mavenhttps://maven.apache.org/download.cgi
方法2:网盘自取
链接:https://pan.baidu.com/s/1DnpanD41EpBGi5EXajh3Vw
提取码:yrg7
第二步:配置环境变量
此电脑--》鼠标右键--》属性—》 高级系统设置--》点击环境变量--》点击系统变量中的新建
新建环境变量:MAVEN_HOME=F:\java\maven\apache-maven-3.8.4(以自己安装的路径为准)
编辑变量Path
第三步:验证maven环境配置是否成功
按住win+R输入cmd弹出命令行窗口 --》输入mvn -version(注意mvn后有个空格)
第四步:配置maven仓库以及相关的设置
1、在maven同级目录下建一个maven仓库
2、打开E:\Java\maven\apache-maven-3.8.4\conf\setting.xml文件
(1)找到结点<localRepository>添加自己仓库的地址
<localRepository>E:\Java\maven\maven-repository</localRepository>(添加自己仓库的地址)
(2)配置镜像,在setting.xml文件中找到mirrors结点,按照如下方式配置
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
(3)在setting.xml文件中找到profiles结点添加:
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
(4)最后在命令行执行命令:mvn help:system(显示Java系统属性和环境变量)首次执行时,会自动下载各种配置文件和类库到Maven本地仓库
【百度网盘中含有setting.xml文件,只需要改自己仓库的位置即可(第(1)步)】
第五步:Maven和Eclipse集成
1、window下选择Preferences后,再选择maven,如图
2、选择installtions,若没有自己安装的maven,通过add选择,apache-maven-3.8.4文件夹的地址
3、钩选自己安装的
4、完成本地设置User Setting
第六步:下载模板创建Spring Boot项目
Spring Initializr
依次选择Project, Language, JDK, Dependencies后,可生成打包的模板(如图所示)
至少应选择SpringBoot DevTools和SpringWeb两个依赖(Dependencies)
点击GENERATE
文件解压后导入eclipse(File-->import-->Maven-->Existing Maven Projects)
点击Finish就开始做项目了。。。。