关闭

Maven安装配置

3556人阅读 评论(0) 收藏 举报

http://maven.apache.org/

http://m2eclipse.codehaus.org/Maven_2.0_Plugin_for_Eclipse.html

 

Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.

 

Maven安装配置:

1.PATH后加上就XXXX/maven-2.0/bin;%PATH%,输入mvn –version验证。

2.如果是代理服务器上网就,setting.xml

<proxies>

 

    <proxy>

      <id>optional</id>

      <active>true</active>

      <protocol>http</protocol>

      <username>proxyuser</username>

      <password>proxypass</password>

      <host>127.3.4.5</host>

      <port>8080</port>

      <nonProxyHosts>local.net,some.host.com</nonProxyHosts>

    </proxy>

  

  </proxies>

3. 让我们看看创建一个简单的Java项目的例子。Maven使用原型来决定目录结构是如何展现的。Maven自带了几个内建的原型,您也可以自定义原型。
  mvn archetype:create -DgroupId=com.oreilly -DartifactId=my-app

4. Compiling Application Sources

       输入:cd my-app;

       mvn compile

5. Compiling Test Sources and Running Unit Tests

mvn test;

mvn test will always run the compile and test-compile phases first, as well as all the others defined before it.

6. Packaging and Installation to Your Local Repository

Making a JAR file is straightforward and can be accomplished by executing the following command:

C:/mvnbook/my-app> mvn package

 

Now, you'll want to install the artifact (the JAR file) you've generated into your local repository. It can then be used by other projects as a dependency. The directory <user_home>/.m2/repository isthe default location of the repository.

To install, execute the following command:

C:/mvnbook/my-app> mvn install

7. Maven2 for eclipse 的插件

http://m2eclipse.codehaus.org/update/

注意:安装plugin时,如果上网是浏览器代理则eclipse也要设置一下,才能联上网

windows->preferences->install/upadate选择Enable HTTP proxy connection

 

 

8.进入项目目录,输入:mvn eclipse:eclipse

生成eclipse项目形式.

 

9. eclipse中导入openfans的时候,需要设置Maven的资源目录,
默认目录
C:/Documents and Settings/pengch/.m2/repository
具体设置方式如 下:

1.
运行eclipse
2.window-->references-->Java-->build path-->classpath variables
3.
"New",名字为:M2_REPO  创建一个目录,指向C:/Documents and Settings/pengch/.m2/repository

 OK

 

如果你希望把安装后的maven2的数据仓库指向其他文件夹,你可以在E:/maven/conf下面找到一个settings.xml文件,打开该文件,找到下面的结点进行修改

<localRepository>E:/maven/.m2/repository</localRepository>

修改M2_REPO属性为E:/maven/.m2/repository

 

 

10.修改 setting.xml文件中的

<localRepository>E:/Maven/repository</localRepository>

 

 

点击browse后找到setting.xml点击reindex local repostiory就可以了。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1079455次
    • 积分:12844
    • 等级:
    • 排名:第1104名
    • 原创:241篇
    • 转载:156篇
    • 译文:0篇
    • 评论:227条
    文章分类
    最新评论