Create a prototype template
1. Run the command above archetype:generate in an empty directory. After downloading the necessary jar package, you must first enter the built-in prototype number;
Choose archetype:1: internal -> org.apache.maven.archetypes:maven-archetype-archetype (An archetype which contains a sample archetype.)2: internal -> org.apache.maven.archetypes:maven-archetype-j2ee-simple (An archetype which contains a simplified sample J2EE application.)3: internal -> org.apache.maven.archetypes:maven-archetype-plugin (An archetype which contains a sample Maven plugin.)4: internal -> org.apache.maven.archetypes:maven-archetype-plugin-site (An archetype which contains a sample Maven plugin site. This archetype can be layered upon an existing Maven plugin project.)5: internal -> org.apache.maven.archetypes:maven-archetype-portlet (An archetype which contains a sample JSR-268 Portlet.)6: internal -> org.apache.maven.archetypes:maven-archetype-profiles ()7: internal -> org.apache.maven.archetypes:maven-archetype-quickstart (An archetype which contains a sample Maven project.)8: internal -> org.apache.maven.archetypes:maven-archetype-site (An archetype which contains a sample Maven site which demonstrates some of the supported document types like APT, XDoc, and FML and demonstrates how to i18n your site. This archetype can be layered upon an existing Maven project.)9: internal -> org.apache.maven.archetypes:maven-archetype-site-simple (An archetype which contains a sample Maven site.)10: internal -> org.apache.maven.archetypes:maven-archetype-webapp (An archetype which contains a sample Maven Webapp project.)Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): 7:
2. After entering any number, continue to download the necessary jar packages. Then, please enter groupId, artifactId, version, package respectively, and confirm.
Define value for property 'groupId': com.aaa Define value for property 'artifactId': bbb Define value for property 'version' 1.0-SNAPSHOT: : 1.0 Define value for property 'package' com.aaa: : project Y: : [INFO] ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- maven-archetype-archetype:1.0 [INFO] -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [INFO] project created from Old (1.x) Archetype in dir: E:/CODE/test/bbb [INFO] ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [INFO] ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3. Browse the Maven project
|-- pom.xml`-- src |-- main | `-- java | `-- com | `-- aaa | `-- bbb | `-- App.java `-- test `-- java `-- com `-- aaa `-- bbb `-- AppTest.java
4. When there are too many built-in prototypes, you can use the -Dfilter command to filter.
mvn archetype:generate -Dfilter=j2ee
5. Run mvn archetype:create-from-project in the pom.xml directory of the Maven project, and the prototype project directory will be generated under the target/generated-sources/archetype directory.
6. In the prototype project pom.xml file, execute mvn insta ll to upload the prototype jar package to the local repository
7. The prototype can be used at this time. Execute mvn archetype:generate -DarchetypeCatalog=local
mvn archetype:generate -DarchetypeCatalog=local[INFO] Scanning for projects...[INFO][INFO] ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- standalone-pom >>>[INFO][INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) < generate-sources @ standalone-pom <<<[INFO][INFO][INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) @ standalone-pom ---[INFO] Generating project in Interactive mode[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)Choose arcetype:1: local -> com.aaa:bbb-archetype (bbb-archetype)Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): :
Next is the same process as the first step.
The above example of using the Maven Archetype plug-in to build a Maven project prototype template is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.