Use the Maven Archetype plug-in to build a Maven project prototype template, archetypemaven
Create a prototype Template
1. Run the command archetype: generate in an empty directory. After downloading the necessary jar package, enter the built-in Prototype number;
1 Choose archetype: 2 1: internal -> org.apache.maven.archetypes:maven-archetype-archetype (An archetype which contains a sample archetype.) 3 2: internal -> org.apache.maven.archetypes:maven-archetype-j2ee-simple (An archetype which contains a simplifed sample J2EE application.) 4 3: internal -> org.apache.maven.archetypes:maven-archetype-plugin (An archetype which contains a sample Maven plugin.) 5 4: internal -> org.apache.maven.archetypes:maven-archetype-plugin-site (An archetype which contains a sample Maven plugin site. 6 This archetype can be layered upon an existing Maven plugin project.) 7 5: internal -> org.apache.maven.archetypes:maven-archetype-portlet (An archetype which contains a sample JSR-268 Portlet.) 8 6: internal -> org.apache.maven.archetypes:maven-archetype-profiles () 9 7: internal -> org.apache.maven.archetypes:maven-archetype-quickstart (An archetype which contains a sample Maven project.)10 8: internal -> org.apache.maven.archetypes:maven-archetype-site (An archetype which contains a sample Maven site which demonstrates11 some of the supported document types like APT, XDoc, and FML and demonstrates how12 to i18n your site. This archetype can be layered upon an existing Maven project.)13 9: internal -> org.apache.maven.archetypes:maven-archetype-site-simple (An archetype which contains a sample Maven site.)14 10: internal -> org.apache.maven.archetypes:maven-archetype-webapp (An archetype which contains a sample Maven Webapp project.)15 Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): 7:
2. After entering any number, continue to download the necessary jar package, and then enter the groupId, artifactId, version, and package respectively, and confirm
1 Define value for property 'groupId': com.aaa 2 Define value for property 'artifactId': bbb 3 Define value for property 'version' 1.0-SNAPSHOT: : 1.0 4 Define value for property 'package' com.aaa: : project 5 6 Y: : 7 8 [INFO] ---------------------------------------------------------------------------- 9 [INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-archetype:1.010 [INFO] ----------------------------------------------------------------------------11 [INFO] Parameter: basedir, Value: E:\CODE\test12 [INFO] Parameter: package, Value: project13 [INFO] Parameter: groupId, Value: com.aaa14 [INFO] Parameter: artifactId, Value: bbb15 [INFO] Parameter: packageName, Value: project16 [INFO] Parameter: version, Value: 1.017 [INFO] project created from Old (1.x) Archetype in dir: E:\CODE\test\bbb18 [INFO] ------------------------------------------------------------------------19 [INFO] BUILD SUCCESS20 [INFO] ------------------------------------------------------------------------21 [INFO] Total time: 11:12 min22 [INFO] Finished at: 2017-12-02T22:00:49+08:0023 [INFO] Final Memory: 17M/58M24 [INFO] ------------------------------------------------------------------------
3. Browse Maven Projects
|-- pom.xml`-- src |-- main | `-- java | `-- com | `-- aaa | `-- bbb | `-- App.java `-- test `-- java `-- com `-- aaa `-- bbb `-- AppTest.java
4. If there are too many built-in prototypes, you can use the-Dfilter command to filter them.
Mvn archetype: generate-Dfilter = j2ee
5. Run mvn archetype: create-from-project in the pom. xml directory of the Maven project. The prototype project directory will be generated under the target/generated-sources/archetype directory.
6. Run mvn install in the pom. xml file of the prototype project to upload the prototype jar package to the local repository.
7. The prototype can be used now. Execute mvn archetype: generate-DarchetypeCatalog = local in an empty directory.
1 mvn archetype:generate -DarchetypeCatalog=local 2 [INFO] Scanning for projects... 3 [INFO] 4 [INFO] ------------------------------------------------------------------------ 5 [INFO] Building Maven Stub Project (No POM) 1 6 [INFO] ------------------------------------------------------------------------ 7 [INFO] 8 [INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) > generate-sources @ standalone-pom >>> 9 [INFO]10 [INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) < generate-sources @ standalone-pom <<<11 [INFO]12 [INFO]13 [INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) @ standalone-pom ---14 [INFO] Generating project in Interactive mode15 [INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)16 Choose archetype:17 1: local -> com.aaa:bbb-archetype (bbb-archetype)18 Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): :
The next step is the same as the first step.