maven创建Java项目和web项目

  1. 创建Java项目

    C:\Users\Administrator\Desktop>mvn archetype:generate -DgroupId=yxyu.xx -Dartifa

    ctId=xx1 -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=fals

    e

  2. 创建web项目

C:\Users\Administrator\Desktop>mvn archetype:generate -DgroupId=yxyu.web -Dartif

actId=testwebapp -DarchetypeArtifactId=maven-archetype-webapp -DinteractivMode=f

alse

[INFO] Scanning for projects...

[INFO]

[INFO] ------------------------------------------------------------------------

[INFO] Building Maven Stub Project (No POM) 1

[INFO] ------------------------------------------------------------------------

[INFO]

[INFO] >>> maven-archetype-plugin:2.3:generate (default-cli) > generate-sources

@ standalone-pom >>>

[INFO]

[INFO] <<< maven-archetype-plugin:2.3:generate (default-cli) < generate-sources

@ standalone-pom <<<

[INFO]

[INFO] --- maven-archetype-plugin:2.3:generate (default-cli) @ standalone-pom --

-

[INFO] Generating project in Interactive mode

[INFO] Using property: groupId = yxyu.web

[INFO] Using property: artifactId = testwebapp

Define value for property 'version':  1.0-SNAPSHOT: :

[INFO] Using property: package = yxyu.web

Confirm properties configuration:

groupId: yxyu.web

artifactId: testwebapp

version: 1.0-SNAPSHOT

package: yxyu.web

 Y: : Y

[INFO] -------------------------------------------------------------------------

---

[INFO] Using following parameters for creating project from Old (1.x) Archetype:

 maven-archetype-webapp:1.0

[INFO] -------------------------------------------------------------------------

---

[INFO] Parameter: groupId, Value: yxyu.web

[INFO] Parameter: packageName, Value: yxyu.web

[INFO] Parameter: package, Value: yxyu.web

[INFO] Parameter: artifactId, Value: testwebapp

[INFO] Parameter: basedir, Value: C:\Users\Administrator\Desktop

[INFO] Parameter: version, Value: 1.0-SNAPSHOT

[INFO] project created from Old (1.x) Archetype in dir: C:\Users\Administrator\D

esktop\testwebapp

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 02:07 min

[INFO] Finished at: 2015-06-26T13:54:37+08:00

[INFO] Final Memory: 11M/26M

[INFO] ------------------------------------------------------------------------


C:\Users\Administrator\Desktop>cd testwebapp


C:\Users\Administrator\Desktop\testwebapp>mvn compile

[INFO] Scanning for projects...

[INFO]

[INFO] ------------------------------------------------------------------------

[INFO] Building testwebapp Maven Webapp 1.0-SNAPSHOT

[INFO] ------------------------------------------------------------------------

[INFO]

[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ testwebapp

 ---

[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e

. build is platform dependent!

[INFO] Copying 0 resource

[INFO]

[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ testwebapp ---

[INFO] No sources to compile

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 1.523 s

[INFO] Finished at: 2015-06-26T13:54:58+08:00

[INFO] Final Memory: 6M/16M

[INFO] ------------------------------------------------------------------------

3.【转】一篇别人的东西:

------------------------------maven3常用命令---------------------------

1、常用命令

    1)创建一个Project

 

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

 

  mvn archetype:generate  固定格式

  -DgroupId         组织标识(包名)

  -DartifactId        项目名称

  -DarchetypeArtifactId    指定ArchetypeId,maven-archetype-quickstart,创建一个Java Project;maven-archetype-webapp,创建一个Web Project

  -DinteractiveMode      是否使用交互模式

    2)编译源代码

mvn compile

    3)编译测试代码

mvn test-compile

    4)清空

mvn clean

    5)运行测试

mvn test

    6)生产站点目录并打包

mvn site-deploy

    7)安装当前工程的输出文件到本地仓库

mvn install

    8)打包

mvn package

    9)先清除再打包

mvn clean package

    10)打成jar包

mvn jar:jar

    11)生成eclipse项目  

mvn eclipse:eclipse

    12)查看帮助信息

mvn help:help

   13)查看maven有哪些项目类型分类

mvn archetype:generate -DarchetypeCatalog=intrenal

 

 

  2、标准的Maven项目结构                                         

                    

    src/main/java  存放项目的源代码

    src/test/java  存放测试源代码

    如果要存放一些配置文件,可以再建立一个目录src/main/resource存放,如存放log4j.properties等


转载于:https://my.oschina.net/u/555061/blog/471218

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值