maven建立Java項目和web項目

  1. 建立Java項目java

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

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

    eeclipse

  2. 建立web項目webapp

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

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

alseui

[INFO] Scanning for projects...spa

[INFO]code

[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)建立一個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

 

 

  二、標準的Maven項目結構                                         

                    

    src/main/java  存放項目的源代碼

    src/test/java  存放測試源代碼

    若是要存放一些配置文件,能夠再創建一個目錄src/main/resource存放,如存放log4j.properties等

相關文章
相關標籤/搜索