[Maven学习笔记三]Maven archetype

编程技术  /  houtizong 发布于 3年前   84

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-12: 1.0-alpha-23: 1.0-alpha-34: 1.0-alpha-45: 1.06: 1.1Choose a number: 6: 5Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.0/maven-archetype-quickstart-1.0.jarDownloaded: 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.pomDownloaded: 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': : LearnMavenDefine value for property 'artifactId': : LearnMaven-ch03Define value for property 'version':  1.0-SNAPSHOT: : 1.0Define value for property 'package':  LearnMaven: : com.tomConfirm properties configuration:groupId: LearnMavenartifactId: LearnMaven-ch03version: 1.0package: 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

 

 

 

 

 

 

 

 

 

 

 

 

 

 

请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!

留言需要登陆哦

技术博客集 - 网站简介:
前后端技术:
后端基于Hyperf2.1框架开发,前端使用Bootstrap可视化布局系统生成

网站主要作用:
1.编程技术分享及讨论交流,内置聊天系统;
2.测试交流框架问题,比如:Hyperf、Laravel、TP、beego;
3.本站数据是基于大数据采集等爬虫技术为基础助力分享知识,如有侵权请发邮件到站长邮箱,站长会尽快处理;
4.站长邮箱:[email protected];

      订阅博客周刊 去订阅

文章归档

文章标签

友情链接

Auther ·HouTiZong
侯体宗的博客
© 2020 zongscan.com
版权所有ICP证 : 粤ICP备20027696号
PHP交流群 也可以扫右边的二维码
侯体宗的博客