安装、配置、更新mirrors为阿里云镜像、新建本地仓库
安装
- 官方下载链接
- 解压复制到自定义文件夹
- 配置.bash_profile或.zshrc,或其他终端
- 文件路径为:/Users/shain/CodeTools/Java/Maven
- 终端:zsh,bash同理
# Maven环境 export MAVEN_HOME=/Users/shain/CodeTools/Java/Maven/3.9.5 export PATH=$PATH:$MAVEN_HOME/bin
- 执行:source ~/.zshrc
- 验证是否安装成功
mvn -v
换源
-
修改conf文件夹下的settings.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>alimaven</id> <mirrorOf>*</mirrorOf> <name>aliyun maven</name> <url>https://maven.aliyun.com/repository/public</url> </mirror> </mirrors>
修改本地仓库位置(也可直接使用默认)
自定义文件夹名和路径
- 创建仓库文件夹
/Users/shain/CodeTools/Java/Maven/maven-repository
- 修改conf文件夹下的settings.xml文件(localRepository位置)
<!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ${user.home}/.m2/repository --> <localRepository>/Users/shain/CodeTools/Java/Maven/maven-repository</localRepository>