maven学习过程记录——初步2

来源:互联网 发布:音频后期软件 编辑:程序博客网 时间:2024/04/28 23:14

一、建maven项目:

        1、先建目录 D:\maven_test\maven\03 

       2、切换到目录下后,运行 mvn  archetype:generate 命令进行项目骨架创建,会提示:‘groupId’:      输入:cn.edu.zttc.hello  ;

    ‘artifactId':        输入:    hello-third  ;

'version':1.0-SNAPSHOT::输入:  0.0.1SNAPSHOT  ;

‘package’:   输入:    cn.edu.zttc.hello::

回车,然后输入’Y‘;整个就创建成功了!!

二、用myeclipse建maven项目:

        1、设置maven环境:在myeclipse属性preferences里面找到maven设置地方:1)设置installations 为:点add,添加D:\apache-maven-3.1.1-bin\apache-maven-3.1.1 ;       2)设置user settings为        D:\java\maven\settings.xml    (如果不改变默认的中央仓库的话,那设置应该就是这样了:C:\Documents and Settings\Administrator\.m2\settings.xml)。

       2、开始新建maven项目:右键new,选择other,找到Myeclipse下的maven,选择maven project,然后next中选择maven-archetype-quickstart后next中设置groupId,artifactId,package等,点完成就ok了!

      3、也可以把前面新建的hello-third项目导入到myeclipse中,现在就用导入的hello-third项目进行maven项目的测试:

          打开pom.xml,在dependencies中添加如下依赖,就可以把前面hello-first模块(注意:hello-first模块必须通过运行mvn clean install 发布到仓库中)做为jar包自动引用到项目中;

    <dependency>
                <groupId>cn.edu.zttc.hello</groupId>
                <artifactId>hello-first</artifactId>
                <version>SNAPSHOT-0.0.1</version>
     </dependency>