Maven 安装与配置
maven 搜索jar包: https://mvnrepository.com/
一、安装
前提:已经安装配置 JDK
1)进入官网下载链接 http://maven.apache.org/download.cgi
选择 版本 (Windows -> binary zip; Linux -> binary tar.gz)
2)解压
解压后,将文件夹复制到要保存的目录,如 D:\Program Files (x86)\ 下
二、配置环境变量
1)新建环境变量 MAVEN_HOME,值是 刚才保存的目录 D:\Program Files (x86)\apache-maven-3.6.3
2)%MAVEN_HOME%\bin\ 添加 到 PATH 环境变量下
3)查看是否安装完成,cmd 下运行“mvn -v”
三、配置 Maven 本地仓库
1)目录 D:\Program Files (x86)\apache-maven-3.6.3\ 下,新建 repository 文件夹,或其他地方
2)D:\Program Files (x86)\apache-maven-3.6.3\conf\settings.xml,修改,将 localRepository 复制出来,然后将本地路径,填入
注:如果不修改,默认将放置 在 ${user.home}/.m2/repository
3)配置 mirror,作用可以从配置的mirror的地方下载
找到 setting.xml 的 mirrors, 修改如下配置
<mirrors> <!-- mirror | Specifies a repository mirror site to use instead of a given repository. The repository that | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used | for inheritance and direct lookup purposes, and must be unique across the set of mirrors. | <mirror> <id>mirrorId</id> <mirrorOf>repositoryId</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://my.repository.com/repo/path</url> </mirror> --> <mirror> <id>nexus-aliyun</id> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> <!-- 剩下就是国外的了,maven官方运维的2号仓库 --> <!-- <mirror> <id>repo2</id> <name>Mirror from Maven Repo2</name> <url>http://repo2.maven.org/maven2/</url> <mirrorOf>central</mirrorOf> </mirror> --> <!-- maven在UK架设的仓库(有时候速度会比官方2号仓库快) --> <!-- <mirror> <id>ui</id> <name>Mirror from UK</name> <url>http://uk.maven.org/maven2/</url> <mirrorOf>central</mirrorOf> </mirror> --> <!-- JBoss的仓库 --> <!-- <mirror> <id>jboss-public-repository-group</id> <mirrorOf>central</mirrorOf> <name>JBoss Public Repository Group</name> <url>http://repository.jboss.org/nexus/content/groups/public</url> </mirror> --> </mirrors>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)