First time here? Get an overview of all topics you'll find answers for on this blog here.

Tired of text/plain ? Have a look at my online courses or YouTube channel for more Java, Spring Framework & Jakarta EE content.

Manually creating a new Java EE Maven project can be quite cumbersome. Creating all required folders and files for a simple JAX-RS endpoint with database access was quite error-prone in the past for me. I constantly mixed up WEB-INF and META-INF with its files and was tired of manually creating the project structure. The bootstrapping of a Spring Boot application on the other side is rather simple with the Spring Initializer. I wanted to have a similar bootstrapping experience with Java EE and so I created a custom Maven Archetype for bootstrap a Java EE 8 and Microprofile 2.0 application in seconds. In this blog post, you will learn how to use this archetype for your own projects.

Using this Maven archetype you'll get a fresh project with the following configurations:

Java EE 8 and Microprofile 2.0.1 dependencies

and dependencies Mockito and JUnit dependencies for efficient testing

and dependencies for efficient testing beans.xml with bean-discovery-mode="all" for ready to go dependency injection

with for ready to go dependency injection persistence.xml configured for JTA persistence unit

configured for JTA persistence unit microprofile-config.properties for internal configurations

for internal configurations a JAX-RS configuration class

configuration class a sample JAX-REST rest endpoint ( /resources/sample )

) a Dockerfile for Payara 5.183 deployment at the root path level

deployment at the root path level a script for a convenient Docker build and deployment for both Windows and Linux/Mac

To use this archetype and to be able to bootstrap a Java EE 8 project you need the following tools:

Java 8 installation

Maven CLI ( mvn ) or the embedded Maven of the IDE of your choice

) or the embedded Maven of the IDE of your choice a running Docker daemon

The formal Maven command for creating a new project from my archetype looks like the following:

mvn archetype:generate -DarchetypeGroupId=de.rieckpil.archetypes \ -DarchetypeArtifactId=javaee8 \ -DarchetypeVersion=1.0.2 \ -DgroupId=<your project Group Id> \ -DartifactId=<your project artifact Id> 1 2 3 4 5 mvn archetype:generate -DarchetypeGroupId=de.rieckpil.archetypes \ -DarchetypeArtifactId=javaee8 \ -DarchetypeVersion=1.0.2 \ -DgroupId=<your project Group Id> \ -DartifactId=<your project artifact Id>

With this command, you just have to fill in your groupId and your artifactId and you'll be prompted to enter a version number or use the default 1.0-SNAPSHOT version.

For an even faster creation, you can use the following command to bypass the interactive mode:

mvn archetype:generate -DarchetypeGroupId=de.rieckpil.archetypes -DarchetypeArtifactId=javaee8 -DarchetypeVersion=1.0.2 -DgroupId=de.rieckpil.blog -DartifactId=javaee-8-microservice -DinteractiveMode=false 1 mvn archetype:generate -DarchetypeGroupId=de.rieckpil.archetypes -DarchetypeArtifactId=javaee8 -DarchetypeVersion=1.0.2 -DgroupId=de.rieckpil.blog -DartifactId=javaee-8-microservice -DinteractiveMode=false

The result will look like the following:

Deploy your Java EE 8 application

With this, you have a ready-to-go Maven project setup for your Java EE 8 application. To deploy the application you can execute the buildAndRun.bat (for Windows) or buildAndRun.sh (for Linux/Mac) file to create the .war , build the Docker image and start a container afterward. If you have issues with executing the buildAndRun.sh with ./buildAndRun.sh just make it executable with chmod +x buildAndRun.sh .

After the Payara server successfully started, you can visit http://localhost:8080/resources/sample and see the result of the sample JAX-RS endpoint.

If you have any problems or improvements for this archetype, feel free to open an issue in the GitHub repository.

Have fun bootstrapping a Java EE 8 project with this archetype,

Phil