Quick revision
The short answer
We create a Maven project with mvn archetype:generate, choosing an archetype such as maven-archetype-quickstart, which writes a pom.xml and the standard layout of src/main/java, src/test/java and src/main/resources. An archetype is a project template packaged as a Maven artifact, with placeholders filled from the groupId, artifactId and package we give it. For a Spring Boot service we use Spring Initializr at start.spring.io or its IDE integration instead, which generates the POM with the Boot parent, the starters and the Maven wrapper.
What to remember
In this answer, we created a plain Maven project with mvn archetype:generate and the quickstart archetype, looked at the standard layout it produces, and saw that an archetype is a template published as a Maven artifact with placeholders filled from our coordinates. For Spring Boot services we used Spring Initializr instead, which sets up the parent, starters and Spring Boot plugin, and we always include the Maven wrapper so everyone builds with the same Maven.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
We create a Maven project with mvn archetype:generate, choosing an archetype such as maven-archetype-quickstart, which writes a pom.xml and the standard layout of src/main/java, src/test/java and src/main/resources. An archetype is a project template packaged as a Maven artifact, with placeholders filled from the groupId, artifactId and package we give it. For a Spring Boot service we use Spring Initializr at start.spring.io or its IDE integration instead, which generates the POM with the Boot parent, the starters and the Maven wrapper.
Why this question is asked
Starting a project correctly takes a minute, and starting it badly costs months: wrong folder layout, missing wrapper, old plugin versions copied from somewhere. Interviewers ask this at junior level to check that we know Maven's conventions and the standard tools for creating projects, and why a Spring Boot project is usually started differently. In this answer, we will create a plain Maven project with an archetype, look at what it produces and why, see what an archetype really is, start a Spring Boot service with Initializr, and add the Maven wrapper.
1Creating a Project With archetype:generate
The archetype plugin creates a new project from a template. We tell it which archetype to use and the coordinates of our new project. Running it without parameters starts an interactive menu; for scripts and documentation, the non-interactive form is clearer.
The archetype version shown is an example; check for the latest one. Notice the three values we supply: the groupId identifies our organisation, the artifactId names the project, and the package is the Java package for the sample code. These are exactly the values the template will fill in.
2What the Generated Project Contains
The result follows Maven's standard directory layout, which every Maven plugin assumes by default. Production code goes in src/main/java, test code in src/test/java, and non-code files such as configuration in src/main/resources. Build output goes into target, which is never committed.
- pom.xmlcoordinates, dependencies, plugins
- src/main/javaproduction code
- src/main/resourcesconfiguration and other files on the classpath
- src/test/java and src/test/resourcestests and test data
- targetbuild output, never committed
5 layers, from the top down. Step through them one at a time.
The reason this layout matters is convention over configuration. Because the folders are where Maven expects them, the POM does not need to say where the sources are, and any developer who knows Maven can find their way around the project immediately. The super POM, Maven's built-in parent of every POM, defines these defaults.
3What an Archetype Really Is
An archetype is itself a Maven artifact, a jar published to a repository like any library. Inside it are template files and a descriptor that lists which files to create. The templates contain placeholders such as ${groupId}, ${artifactId} and ${package}, which the archetype plugin replaces with our values, and it also moves the Java files into folders that match the package.
Because archetypes are ordinary artifacts, anyone can publish one. Many frameworks once shipped archetypes, and a company can build its own from an existing project with mvn archetype:create-from-project, then publish it to its repository manager. That is the main reason archetypes are still used: an internal archetype gives every new project the company's defaults.
4Starting a Spring Boot Service With Spring Initializr
For Spring Boot, the standard starting point is Spring Initializr, the service at start.spring.io. We choose Maven, a Java version, a Spring Boot version and the starters we want, such as Spring Web and Actuator, and it generates a ready project. The same service powers the new-project wizards in IntelliJ IDEA, VS Code and Spring Tools, and it can be called from the command line.
The reason we prefer Initializr over a generic archetype is that it knows Spring Boot: it sets the right parent, which brings tested dependency versions and plugin configuration, picks compatible starters, includes the Spring Boot Maven plugin for building an executable jar, and stays current with each Spring Boot release. A generic archetype would leave all of that to us.
5Always Include the Maven Wrapper
The Maven wrapper is a small script, mvnw on Linux and macOS and mvnw.cmd on Windows, plus a properties file in .mvn/wrapper that names a Maven version. When we run ./mvnw verify, the script downloads that exact Maven version if needed and runs it. So every developer and every CI job builds with the same Maven, without installing it by hand. Initializr includes it; for other projects we add it with the wrapper plugin.
The Maven version shown is an example; use the current one for your project. Commit the wrapper files so they travel with the code.
6Company Starting Points
Larger companies often go one step further and publish their own starting point: an internal archetype, or their own instance of Spring Initializr, which is open source and can be customised with company defaults such as the corporate parent, internal starters and repository settings. New services then begin with the right setup instead of a copy of an old one.
7Follow-up questions
What is the difference between mvn archetype:generate and copying an existing project?
The archetype produces a clean project from a maintained template, with our own coordinates and package filled in. Copying an old project brings its leftovers: outdated plugin versions, unused dependencies, old configuration and sometimes its name in places we forget to change. That is why companies that grow quickly invest in a maintained template.
Can Spring Initializr be used offline or inside a company?
Yes. Initializr is an open source project, so a company can run its own instance with its own defaults, dependencies and versions, and point IDEs at it. That gives developers the familiar wizard with the company's conventions built in.
Why is the Maven wrapper better than requiring an installed Maven?
Because builds then depend on whatever Maven each person installed, which drifts over time. With the wrapper, the version is part of the repository, so upgrading Maven is a reviewed change in one file and every build, local and CI, uses the same version.
8Conclusion
In this answer, we created a plain Maven project with mvn archetype:generate and the quickstart archetype, looked at the standard layout it produces, and saw that an archetype is a template published as a Maven artifact with placeholders filled from our coordinates. For Spring Boot services we used Spring Initializr instead, which sets up the parent, starters and Spring Boot plugin, and we always include the Maven wrapper so everyone builds with the same Maven.
Open with
To create a plain Maven project, I run mvn archetype:generate with an archetype such as maven-archetype-quickstart, and pass the groupId, artifactId and package, usually with interactiveMode false. That gives me a pom.xml and the standard layout: src/main/java, src/test/java and src/main/resources, with output going to target.
Then, if they want more
Maven assumes that layout through the super POM, which is why a small POM is enough. An archetype is just a project template packaged as a Maven artifact. It contains template files with placeholders like groupId, artifactId and package, and the archetype plugin fills them in with my values.
Companies can create one from an existing project with archetype:create-from-project and publish it internally. For a Spring Boot service, though, I would not use a generic archetype. I would use Spring Initializr, either start.spring.io, the IDE wizard or curl, and pick Maven, the Java version and starters like web and actuator.
It generates a POM with spring-boot-starter-parent, the starters, the Spring Boot Maven plugin and the Maven wrapper. I always keep the wrapper, mvnw, in the repository, so every developer and CI job uses the same Maven version.
And in bigger companies, an internal archetype or an internal Initializr instance with company defaults is a good way to start every service the same way.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Apache Maven guides
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "How do you create a new Maven project from scratch, and what is an archetype? What would...": https://scrivio-interview-library.netlify.app/java/maven/f777286e15/