下载

image.png

安装

  • 压缩包解压后,再往里一层的位置才是maven安装的路径

image.png

配置环境变量

  • 配置环境变量MAVEN_HOME,路径即为maven的根路径
  • (例:D:\Program Files\apache-maven-3.6.3-bin\apache-maven-3.6.3)

image.png

  • 添加 %MAVEN_HOME%\bin;环境变量到Path的最后

image.png

  • 控制台输入mvn -v查看maven是否配置成功

image.png

修改配置文件

  • 编辑D:\Program Files\apache-maven-3.6.3-bin\apache-maven-3.6.3\conf\settings.xml
  • maven默认会把依赖包存在C盘,打开此处的注释修改成自己创建的文件夹

image.png

  • maven默认会从国外的镜像库下载依赖文件,非常慢,在mirrors节点中添加下面列出来的国内镜像节点

    注:我已经把镜像节点添加到提供的安装文件压缩包里了

image.png

  1. <mirror>
  2. <id>alimaven</id>
  3. <mirrorOf>central</mirrorOf>
  4. <name>aliyun maven</name>
  5. <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
  6. </mirror>
  7. <mirror>
  8. <id>alimaven</id>
  9. <name>aliyun maven</name>
  10. <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
  11. <mirrorOf>central</mirrorOf>
  12. </mirror>
  13. <mirror>
  14. <id>ibiblio</id>
  15. <mirrorOf>central</mirrorOf>
  16. <name>Human Readable Name for this Mirror.</name>
  17. <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
  18. </mirror>
  19. <mirror>
  20. <id>jboss-public-repository-group</id>
  21. <mirrorOf>central</mirrorOf>
  22. <name>JBoss Public Repository Group</name>
  23. <url>http://repository.jboss.org/nexus/content/groups/public</url>
  24. </mirror>
  25. <mirror>
  26. <id>central</id>
  27. <name>Maven Repository Switchboard</name>
  28. <url>http://repo1.maven.org/maven2/</url>
  29. <mirrorOf>central</mirrorOf>
  30. </mirror>
  31. <mirror>
  32. <id>repo2</id>
  33. <mirrorOf>central</mirrorOf>
  34. <name>Human Readable Name for this Mirror.</name>
  35. <url>http://repo2.maven.org/maven2/</url>
  36. </mirror>