archetype插件用于创建符合maven规定的目录骨架
方式一:根据提示设置相关参数
guowli@5CG450158J MINGW64 /d/Anliven-Running/Zen/EclipseProjects
$ ll
total 4
drwxr-xr-x 1 guowli 1049089 0 Sep 1 16:50 Test/
drwxr-xr-x 1 guowli 1049089 0 Oct 20 17:14 TestMaven/
drwxr-xr-x 1 guowli 1049089 0 Oct 20 17:28 TestMaven02/
guowli@5CG450158J MINGW64 /d/Anliven-Running/Zen/EclipseProjects
$ mkdir TestMaven03
guowli@5CG450158J MINGW64 /d/Anliven-Running/Zen/EclipseProjects
$ cd TestMaven03
guowli@5CG450158J MINGW64 /d/Anliven-Running/Zen/EclipseProjects/TestMaven03
$ mvn archetype:generate
[INFO] Scanning for projects...
Downloading: http://central.maven.org/maven2/org/apache/maven/plugins/maven-deploy-plugin/2.7/maven-deploy-plugin-2.7.pom
......
......
......
Choose archetype:
1: remote -> am.ik.archetype:maven-reactjs-blank-archetype (Blank Project for React.js)
......
......
......
1057: remote -> org.apache.maven.archetypes:maven-archetype-quickstart (An archetype which contains a sample Maven project.)
......
......
......
1962: remote -> us.fatehi:schemacrawler-archetype-plugin-lint (-)
Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): 1057:
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: 6
......
......
......
Define value for property 'groupId': anliven.testmaven03
Define value for property 'artifactId': testmaven03
Define value for property 'version' 1.0-SNAPSHOT: : 0.0.1-SNAPSHOT
Define value for property 'package' anliven.testmaven03: : anliven.testmaven03
Confirm properties configuration:
groupId: anliven.testmaven03
artifactId: testmaven03
version: 0.0.1-SNAPSHOT
package: anliven.testmaven03
Y: : Y
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-quickstart:1.1
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: basedir, Value: D:Anliven-RunningenEclipseProjectsTestMaven03
[INFO] Parameter: package, Value: anliven.testmaven03
[INFO] Parameter: groupId, Value: anliven.testmaven03
[INFO] Parameter: artifactId, Value: testmaven03
[INFO] Parameter: packageName, Value: anliven.testmaven03
[INFO] Parameter: version, Value: 0.0.1-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: D:Anliven-RunningenEclipseProjectsTestMaven03 estmaven03
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 06:25 min
[INFO] Finished at: 2017-10-20T17:56:44+08:00
[INFO] Final Memory: 17M/208M
[INFO] ------------------------------------------------------------------------
guowli@5CG450158J MINGW64 /d/Anliven-Running/Zen/EclipseProjects/TestMaven03
$ ls -l
total 0
drwxr-xr-x 1 guowli 1049089 0 Oct 20 17:56 testmaven03/
guowli@5CG450158J MINGW64 /d/Anliven-Running/Zen/EclipseProjects/TestMaven03
$ ls -l testmaven03/
total 4
-rw-r--r-- 1 guowli 1049089 790 Oct 20 17:56 pom.xml
drwxr-xr-x 1 guowli 1049089 0 Oct 20 17:56 src/
guowli@5CG450158J MINGW64 /d/Anliven-Running/Zen/EclipseProjects/TestMaven03
$ ls -l testmaven03/src/main/java/anliven/testmaven03/App.java
-rw-r--r-- 1 guowli 1049089 195 Oct 20 17:56 testmaven03/src/main/java/anliven/testmaven03/App.java
guowli@5CG450158J MINGW64 /d/Anliven-Running/Zen/EclipseProjects/TestMaven03
$ ls -l testmaven03/src/test/java/anliven/testmaven03/AppTest.java
-rw-r--r-- 1 guowli 1049089 685 Oct 20 17:56 testmaven03/src/test/java/anliven/testmaven03/AppTest.java
方式二:一次性指定相关参数
$ mvn archetype:generate -DgroupId=anliven.testmaven03 -DartifactId=testmaven03 -Dversion= 0.0.1-SNAPSHOT -Dpackage=anliven.testmaven03
- -DgroupId=组织名,公司网址的反写+项目名
- -DartifactId=项目名-模块名
- -Dversion=版本号
- -Dpackage=代码所在的包名