What is an archetype in Maven?

By | October 27, 2020

In this post, We will talk and learn about What is an archetype in Maven? 

  • An archetype is nothing but the template provided by the maven to create a project.
  • There is a huge number of maven archetypes listed out in order to create projects under different frameworks like spring, spring boot, hibernate, struts, web services (RESTful/SOAP), and many others.
  • We can create the Workspace directory wherever we want on our PC or use the Workspace if already created. Then type the below maven command (it’s a single line command) and press enter.

Above maven command will create a Java project with the following details:

  • groupId will be com.kkjavatutorials.samples, representing the package.
  • artifactId will be JavaSampleProject (on the build, JavaSampleProject.jar will be created)
  • archetypeArtifactId is the template used for creating this Java project.
  • interactiveMode is used when the developer is very well aware of the actual spelling of the artifact id. In our case, maven-archetype-quickstart is the correct one. If the software developer is not well aware of the artifact id correct spelling then the interactiveMode is set to be TRUE so that it will scan the remote repositories for all available archetypes. This might take a longer time.

The table below describes the main directories that are created as a part of the project.

Directory Description
JavaSampleProject The root folder of the project containing source and pom.xml
src\main\java Contains all the java code under the package com.kkjavatutorials.samples
src\main\test Contains all the java test code under the package com.kkjavatutorials.samples
src\main\resources Contains all the resources like xml\properties file etc..

That’s all about What is an archetype in Maven?
If you have any feedback or suggestion please feel free to drop in below comment box.

Leave a Reply

Your email address will not be published. Required fields are marked *