您的位置:首页 > 编程语言 > Java开发

Maven 及其在Eclipse 中的插件的安装

2014-03-06 23:39 267 查看
记录为了自己方便。

1. Maven 安装

下载,找个合适的包: http://maven.apache.org/download.cgi。 解压就可以了,不用再安装。

如我的路径: D:\java\maven\apache-maven-3.1.1 (去年了带bin 的文件夹)

2. Maven 配置

[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.] => 使用maven 前需确保Java, JDK 已安装。

2.1 环境变量

a, 在系统变量里加一项:M2_HOME



b. 系统变量的Path 里加入:%M2_HOME%\bin

我自己的win7 系统用b 中变量不管用,所以把maven 中bin 的全路径给加进去:D:\java\maven\apache-maven-3.1.1\bin

2.2 maven 的配置文件

下面贴原文:

There are two locations where a settings.xml file may live:
The Maven install: $M2_HOME/conf/settings.xml
A user's install: ${user.home}/.m2/settings.xml
The former settings.xml are also called global settings, the latter settings.xml are referred to as user settings. If both files exists, their contents gets merged,
with the user-specific settings.xml being dominant. => 第一个文件是全局的,第二个是局部的,两个设置文件的设置叠加工作,冲突则以第二个为主。
Tip: If you need to create user-specific settings from scratch, it's easiest to copy the global settings from your Maven installation to your ${user.home}/.m2 directory. Maven's
default settings.xml is a template with comments and examples so you can quickly tweak it to match your needs. => 所以想要定制一些设置,则把该文件从第一个地方复制到第二个地方。然后再去改。
挺多设置可以改的,具体看官方介绍:http://maven.apache.org/settings.html
有一个叫localRepository的,这个是指定maven 将下载的依赖包的放置的地方。

根据需要编辑保存。

3. Maven 在eclipse 中的插件

安装: Help -> Install New Software -> Add => e2eclipse/http://download.eclipse.org/technology/m2e/releases

4. M2E-Android

[The Android Configurator is an Maven Integration for Eclipse (m2e) plug-in that adds maven support for Android Developer Tools (ADT) and the Maven Android Plugin. It brings the power of Maven dependency management into the ADT.]

Install:  

You will need Eclipse
Indigo or Juno installed.  Help -> Eclipse Marketplace... -> install plug-in and its dependencies -> finish

5. 建立Maven的project

File--new—other—Java Maven Project

        



         



6. 应用Maven来打包Project

    在cmd中的命令:

      a. mvn eclipse:clean         清除Project中以前的编译的东西,重新再来

      b. mvn eclipse:eclipse       开始编译Maven的Project

    在Myeclipse中的操作:

      a. 选中Maven Project 右击 在Run As中选择Maven clean

      b. 在Myeclipse中,Project—Clean  开始编译

      c. 选中Maven Project 右击 在Run As中选择Maven install

     执行完这几步,如果没发生异常,会在project里生成一个target文件夹,这个文件夹里的东西,就是Maven为你打包发布的东西。

参考:
http://www.cnblogs.com/good_hans/archive/2010/03/22/1691965.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  maven