Build an instance of the Maven engineering prototype template using the Maven Archetype plug in

  • 2020-12-09 00:53:59
  • OfStack

Create a prototype template

1. Run the command above archetype:generate in an empty directory. After downloading the necessary jar package, you first need to 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 simplifed 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:

After 2, enter any number, and continue to download the necessary jar package, request input groupId respectively, after artifactId, version, package, and confirm it


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] ----------------------------------------------------------------------------
 [INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-archetype:1.0
 [INFO] ----------------------------------------------------------------------------
 [INFO] Parameter: basedir, Value: E:\CODE\test
 [INFO] Parameter: package, Value: project
 [INFO] Parameter: groupId, Value: com.aaa
 [INFO] Parameter: artifactId, Value: bbb
 [INFO] Parameter: packageName, Value: project
 [INFO] Parameter: version, Value: 1.0
 [INFO] project created from Old (1.x) Archetype in dir: E:\CODE\test\bbb
 [INFO] ------------------------------------------------------------------------
 [INFO] BUILD SUCCESS
 [INFO] ------------------------------------------------------------------------
 [INFO] Total time: 11:12 min
 [INFO] Finished at: 2017-12-02T22:00:49+08:00
 [INFO] Final Memory: 17M/58M
 [INFO] ------------------------------------------------------------------------

3. Browse 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 -ES21en command to filter


mvn archetype:generate -Dfilter=j2ee

5. Run mvn archetype: ES30en-ES31en-ES32en in pom. xml directory of Maven project, and the prototype project directory will be generated under target/ ES34en-ES35en /archetype directory

6. Under the prototype project ES39en.xml file, execute mvn install to upload the prototype jar package to the local warehouse

7. At this point, the prototype is ready to be used. Execute mvn archetype: ES48en-ES49en =local in the empty directory


mvn archetype:generate -DarchetypeCatalog=local
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) > generate-sources @ 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 archetype:
1: local -> com.aaa:bbb-archetype (bbb-archetype)
Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): :

Here is the same process as in Step 1.


Related articles: