Maven 安装

本文记录了使用Maven过程中遇到的网络问题及解决方案。作者尝试了多种镜像源但未解决问题,最终通过断开本地网络连接并使用手机热点成功下载。

安装maven后,在下载时总出问题:

 

E:\Maven_Project>mvn help:sytem
[INFO] Scanning for projects...
Downloading: http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-clean-plugin:2.4.1: Plugin org.apache.maven.plugins:maven-clean-plug
in:2.4.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.4.
1
Downloading: http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/maven/plugins/maven-install-plugin/2.3.1/maven-install-plugin-2.3.1.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-install-plugin:2.3.1: Plugin org.apache.maven.plugins:maven-install-
plugin:2.3.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-install-plugin:ja
r:2.3.1
Downloading: http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/maven/plugins/maven-deploy-plugin/2.7/maven-deploy-plugin-2.7.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-deploy-plugin:2.7: Plugin org.apache.maven.plugins:maven-deploy-plug
in:2.7 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-deploy-plugin:jar:2.7
Downloading: http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/maven/plugins/maven-site-plugin/3.0/maven-site-plugin-3.0.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-site-plugin:3.0: Plugin org.apache.maven.plugins:maven-site-plugin:3
.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-site-plugin:jar:3.0
Downloading: http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/maven/plugins/maven-antrun-plugin/1.3/maven-antrun-plugin-1.3.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-antrun-plugin:1.3: Plugin org.apache.maven.plugins:maven-antrun-plug
in:1.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-antrun-plugin:jar:1.3
Downloading: http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-5/maven-assembly-plugin-2.2-beta-5.
pom

 

最后确定是网络问题。

http://blog.youkuaiyun.com/shiqidide/article/details/7659310http://www.iteye.com/problems/80295 和http://maven.apache.org/guides/mini/guide-mirror-settings.html

经测试,各个mirror都不行,断开本地连接,直接用手机上网,可以了╮(╯_╰)╭

### 如何安装 Maven #### 1. 下载 Maven 访问 Apache 官方网站下载最新版本的 Maven。可以选择适合操作系统的二进制压缩包进行下载[^2]。 #### 2. 解压并设置安装路径 将下载好的压缩包解压至指定目录,例如 `E:\Maven\apache-maven-3.2.5`[^4]。此目录将成为 Maven安装根目录。 #### 3. 配置环境变量 为了能够在任意位置运行 Maven 命令,需配置系统环境变量: - 打开系统属性 -> 环境变量。 - 在 `Path` 中添加 Maven 的 `bin` 路径,例如:`E:\Maven\apache-maven-3.2.5\bin`。 #### 4. 验证安装是否成功 打开命令提示符窗口,输入以下命令验证安装情况: ```bash mvn -v ``` 如果返回的信息中包含了 JDK 版本、OS 名称以及 Maven 版本,则表示安装成功。 #### 5. 配置本地仓库 默认情况下,Maven 使用 `${user.home}/.m2/repository` 作为本地仓库地址。可以通过修改 `settings.xml` 文件中的 `<localRepository>` 属性来更改该路径[^3]。 #### 6. IDEA 中配置 Maven 对于使用 IntelliJ IDEA 开发工具的用户,可以进入 **File | Settings | Build, Execution, Deployment | Build Tools | Maven** 进行相关配置,包括指定 Maven 主目录和自定义设置文件的位置。 #### 7. Java 编译器版本配置 编辑 `conf/settings.xml` 或者项目的 `pom.xml` 文件,在其中加入如下片段以适配特定版本的 JDK: ```xml <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> ``` 上述 XML 结构用于激活对应版本的编译选项[^5]。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值