[Maven学习笔记三]Maven archetype

archetype的英文意思是原型,Maven archetype表示创建Maven模块的模版,比如创建web项目,创建Spring项目等等.

 

mvn archetype提供了一种命令行交互式创建Maven项目或者模块的方式,

 

mvn archetype

 

1.在LearnMaven-ch03目录下,执行命令mvn archetype:generate,以交互式的方式创建Maven模块

Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): 439: 【此处直接回车】
Choose org.apache.maven.archetypes:maven-archetype-quickstart version: 
1: 1.0-alpha-1
2: 1.0-alpha-2
3: 1.0-alpha-3
4: 1.0-alpha-4
5: 1.0
6: 1.1
Choose a number: 6: 5
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.0/maven-archetype-quickstart-1.0.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.0/maven-archetype-quickstart-1.0.jar (5 KB at 4.7 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.0/maven-archetype-quickstart-1.0.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.0/maven-archetype-quickstart-1.0.pom (703 B at 1.8 KB/sec)
Define value for property 'groupId': : LearnMaven
Define value for property 'artifactId': : LearnMaven-ch03
Define value for property 'version':  1.0-SNAPSHOT: : 1.0
Define value for property 'package':  LearnMaven: : com.tom
Confirm properties configuration:
groupId: LearnMaven
artifactId: LearnMaven-ch03
version: 1.0
package: com.tom
 Y: : y
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-quickstart:1.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: LearnMaven
[INFO] Parameter: packageName, Value: LearnMaven
[INFO] Parameter: package, Value: LearnMaven
[INFO] Parameter: artifactId, Value: LearnMaven-ch03
[INFO] Parameter: basedir, Value: ~/development/learnmaven/maven-ch03
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: ~/development/learnmaven/maven-ch03/LearnMaven-ch03
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 05:46 min
[INFO] Finished at: 2014-08-02T11:59:45+08:00
[INFO] Final Memory: 16M/173M
[INFO] ------------------------------------------------------------------------

 

执行完成后在~/development/learnmaven/LearnMaven-ch03创建了pom.xml以及src目录,

 

2. 在~/development/learnmaven/LearnMaven-ch03目录执行命令mvn test可以看到使用archetype原型创建的项目成功执行单元测试

 

mvn archetype:generate -D

也可以使用-D参数指定我们在上面使用archetype:generate输入的参数,不过不指定则使用缺省值,如

mvn archetype:generate -DgroupId=LearnMaven -DartifactId=maven-ch03 -Dversion=1.0 -Dpackage=com.tom

 

执行结果同mvn archetype:generate

 

 

 

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(ArcheType)