8 使用Maven模板创建项目

使用mvn archetype:generate从现有的Maven模板列表中生成项目。在Maven 3.3.3,有超过1000+个模板,Maven 团队已经过滤掉一些无用的模板。

  • 通常情况下,我们只需要使用下面的两个模板:
maven-archetype-webapp – Java Web Project (WAR)
maven-archetype-quickstart – Java Project (JAR)

1. Maven 1000+ 模板

如果键入命令mvn archetype:generate,1000 +模板会被提示在屏幕上,你没有办法看到它,或者选择什么。为了解决这个问题,输出模板列表,像这样保存为文本文件:

E:\WorkSpace\Study>mvn archetype:generate > templates.txt //waiting few seconds,
then exits


2. Maven archetype:generate

步骤来指导你如何从现有 Spring-Hibernate 模板来构建Web项目:

  • 2.1 列出 Maven 的模板:
E:\WorkSpace\Study>mvn archetype:generate

......
Choose a number or apply filter (format: [groupId:]artifactId, case sensitive co
ntains): 967: 314

Choose org.jboss.spec.archetypes:jboss-javaee6-webapp-ear-blank-archetype versio
n:
1: 7.1.1.Beta1
2: 7.1.1.Beta2
3: 7.1.1.Beta3
4: 7.1.1.CR1
5: 7.1.1.Final
6: 7.1.2.CR1
7: 7.1.2.CR2
8: 7.1.2.Final
9: 7.1.3.CR1
10: 7.1.3.CR2
11: 7.1.3.CR3
12: 7.1.3.CR4
13: 7.1.3.CR5
14: 7.1.3.CR6
15: 7.1.3.CR7
16: 7.1.3.CR8
17: 7.1.3.CR9
18: 7.1.3.Final
Choose a number: 18: 6

......
[INFO] Parameter: artifactId, Value: MavenTemplate
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.gp6
[INFO] Parameter: packageInPathFormat, Value: com/gp6
[INFO] Parameter: package, Value: com.gp6
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: com.gp6
[INFO] Parameter: jboss-bom-enterprise-version, Value: 1.0.2.Final-redhat-1
[INFO] Parameter: artifactId, Value: MavenTemplate
[INFO] Parameter: enterprise, Value: false
[INFO] Parent element not overwritten in E:\WorkSpace\Study\MavenTemplate\MavenT
emplate-ejb\pom.xml
[INFO] Parent element not overwritten in E:\WorkSpace\Study\MavenTemplate\MavenT
emplate-web\pom.xml
[INFO] Parent element not overwritten in E:\WorkSpace\Study\MavenTemplate\MavenT
emplate-ear\pom.xml
[INFO] Project created from Archetype in dir: E:\WorkSpace\Study\MavenTemplate
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:37 min
[INFO] Finished at: 2017-05-03T16:56:35+08:00
[INFO] Final Memory: 19M/228M
[INFO] ------------------------------------------------------------------------

你可能感兴趣的:(8 使用Maven模板创建项目)