Creating a Java project using Maven archetype
Avoid the DRY (Don’t Repeat Yourself) when a new Java project should be created.
New Java project is less error prone due to copy/paste from previous projects.
Use the Maven archetype to create the projects, via command line or by IntelliJ.
3.1 Command line
An example of a Maven archetype site.
Project structure, after running the
mvn clean test command. Using Mac the zsh doesn’t have a tree program, then use this alias.
Well, there are some weird folders, right? Yes. Then you can create your own or choose another from the many options, as will be shown below.
Create a new project and then select Maven, Create from archetype
Select the maven-archetype-quickstart:RELEASE
Fill/Change the values
And hit the Finish button
And then, the project is loaded. The Java version of this archetype is 1.7 (old). If you prefer, create your own archetype :).
As expected it is better to use an archetype rather than copy/rename files. Although, sometimes the archetype doesn’t fit well for you, so it is great to know how to tailor one for you.
Basic Java Maven Archetypes
This is a collection of basic Maven Archetypes to create simple projects with Java and updated libraries. The first of…
Maven - Introduction to Archetypes
Introduction to Archetypes In short, Archetype is a Maven project templating toolkit. An archetype is defined as an…