maven 安装

http://maven.apache.org/download.html

===================================================

maven 执行

官方说明:http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

 

mvn clean dependency:copy-dependencies package

This command will clean the project, copy dependencies, and package the project (executing all phases up to package, of course).

 

mvn eclipse:eclipse

======================================================

maven  安装

Installation Instructions

 

Maven Documentation

You can download the current documentation, i.e. this website, as:

Previous Releases

All previous releases of Maven can be found in the archives.

System Requirements

JDK1.5 or above (this is to execute Maven - it still allows you to build against 1.3 and prior JDK's)
MemoryNo minimum requirement
DiskNo minimum requirement. Approximately 100MB will be used for your local repository, however this will vary depending on usage and can be removed and redownloaded at any time.
Operating SystemNo minimum requirement. On Windows, Windows NT and above or Cygwin is required for the startup scripts. Tested on Windows XP, Fedora Core and Mac OS X.

Installation Instructions

Maven is a Java tool, so you must have Java installed in order to proceed. More precisely, you need a Java Development Kit (JDK), the Java Runtime Environment (JRE) is not sufficient.

Additional optional installation steps are listed after the platform specific instructions.

Windows 2000/XP
  1. Unzip the distribution archive, i.e. apache-maven-3.0.4-bin.zip to the directory you wish to install Maven 3.0.4. These instructions assume you chose C:\Program Files\Apache Software Foundation. The subdirectory apache-maven-3.0.4 will be created from the archive.
  2. Add the M2_HOME environment variable by opening up the system properties (WinKey + Pause), selecting the "Advanced" tab, and the "Environment Variables" button, then adding the M2_HOME variable in the user variables with the value C:\Program Files\Apache Software Foundation\apache-maven-3.0.4. Be sure to omit any quotation marks around the path even if it contains spaces. Note: For Maven < 2.0.9, also be sure that the M2_HOME doesn't have a '\' as last character.
  3. In the same dialog, add the M2 environment variable in the user variables with the value %M2_HOME%\bin.
  4. Optional: In the same dialog, add the MAVEN_OPTS environment variable in the user variables to specify JVM properties, e.g. the value -Xms256m -Xmx512m. This environment variable can be used to supply extra options to Maven.
  5. In the same dialog, update/create the Path environment variable in the user variables and prepend the value %M2% to add Maven available in the command line.
  6. In the same dialog, make sure that JAVA_HOME exists in your user variables or in the system variables and it is set to the location of your JDK, e.g. C:\Program Files\Java\jdk1.5.0_02 and that %JAVA_HOME%\bin is in your Path environment variable.
  7. Open a new command prompt (Winkey + R then type cmd) and run mvn --version to verify that it is correctly installed.
Unix-based Operating Systems (Linux, Solaris and Mac OS X)
  1. Extract the distribution archive, i.e. apache-maven-3.0.4-bin.tar.gz to the directory you wish to install Maven 3.0.4. These instructions assume you chose /usr/local/apache-maven. The subdirectory apache-maven-3.0.4 will be created from the archive.
  2. In a command terminal, add the M2_HOME environment variable, e.g. export M2_HOME=/usr/local/apache-maven/apache-maven-3.0.4.
  3. Add the M2 environment variable, e.g. export M2=$M2_HOME/bin.
  4. Optional: Add the MAVEN_OPTS environment variable to specify JVM properties, e.g. export MAVEN_OPTS="-Xms256m -Xmx512m". This environment variable can be used to supply extra options to Maven.
  5. Add M2 environment variable to your path, e.g. export PATH=$M2:$PATH.
  6. Make sure that JAVA_HOME is set to the location of your JDK, e.g. export JAVA_HOME=/usr/java/jdk1.5.0_02 and that $JAVA_HOME/bin is in your PATH environment variable.
  7. Run mvn --version to verify that it is correctly installed.
Optional configuration

Maven will work for most tasks with the above configuration, however if you have any environmental specific configuration outside of individual projects then you will need to configure settings. The following sections refer to what is available.

Settings

Maven has a settings file located in the Maven installation and/or user home directory that configure environmental specifics such as:

  • HTTP proxy server
  • repository manager location
  • server authentication and passwords
  • other configuration properties

For information on this file, see the Settings reference

Security

As of Maven 2.1.0+, you can encrypt passwords in your settings file, however you must first configure a master password. For more information on both server passwords and the master password, see the Guide to Password Encryption.

Toolchains

As of Maven 2.0.9+, you can build a project using a specific version of JDK independent from the one Maven is running with. For more information, see the Guide to Using Toolchains.

### 如何安装 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、付费专栏及课程。

余额充值