Micronaut projects are designed to have a clean and modular structure. Whether you use Gradle or Maven as your build tool, the project organization remains similar.
In this post, we will focus on Micronaut projects created with Maven. I’ll explain each folder and file simply, so even if you’re completely new, you’ll quickly understand how everything fits together in a project structure in Micronaut.

Step 1 — Generate a Micronaut Project Using Maven
We’ll use the Micronaut CLI to generate a project using Maven.
Command:
1 2 3 4 |
mn create-app com.kscodes.micronaut.sample --build=maven --lang=java |
Explanation:
com.kscodes.micronaut.sample
→ your package name.--build=maven
→ we are using Maven instead of Gradle.--lang=java
→ we are using Java.
Step 2 — Project Structure Overview
Once generated, your Micronaut Maven project will look like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
sample/ ├── mvnw ├── mvnw.cmd ├── pom.xml ├── README.md ├── src/ │ ├── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── kscodes/ │ │ │ └── micronaut/ │ │ │ └── sample/ │ │ │ └── Application.java │ │ └── resources/ │ │ ├── application.yml │ │ └── logback.xml │ └── test/ │ ├── java/ │ └── resources/ └── ... |
Now, let’s break down each section.
Step 3 — Top-Level Files
1️⃣ pom.xml
- This is the Maven build configuration file.
- It defines dependencies, plugins, and project info.
Example snippet:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
<project> <modelversion>4.0.0</modelversion> <groupid>com.kscodes.micronaut</groupid> <artifactid>sample</artifactid> <version>0.1</version> <dependencies> <dependency> <groupid>io.micronaut</groupid> <artifactid>micronaut-runtime</artifactid> </dependency> </dependencies> <build> <plugins> <plugin> <groupid>io.micronaut.build</groupid> <artifactid>micronaut-maven-plugin</artifactid> <version>4.0.0</version> </plugin> </plugins> </build> </project> |
All your Micronaut dependencies and plugins go here.
Much like Gradle’s build.gradle
, but in XML format.
2️⃣ mvnw
and mvnw.cmd
- These are the Maven Wrapper scripts.
- They ensure anyone can build the project without having Maven installed globally.
mvnw
is for Mac/Linux, andmvnw.cmd
is for Windows.
3️⃣ README.md
- Simple file explaining how to run and build your project.
Step 4 — src/main
Folder
1️⃣ src/main/java/
- All your Java application source code lives here.
Example file:Application.java
1 2 3 4 5 6 7 8 9 10 11 12 |
package com.kscodes.micronaut.sample; import io.micronaut.runtime.Micronaut; public class Application { public static void main(String[] args) { Micronaut.run(Application.class, args); } } |
This is the entry point for your Micronaut application.
2️⃣ src/main/resources/
Contains all your resource files such as configurations and logging:
application.yml
- Used for Micronaut configuration.
Example:
1 2 3 4 5 6 |
micronaut: application: name: sample |
logback.xml
- Used to configure logging for your application.
Step 5 — src/test
Folder
This folder contains your test cases and test configurations.
1️⃣ src/test/java/
- You’ll write your JUnit or Micronaut tests here.
Example:
1 2 3 4 5 6 7 8 9 10 11 |
package com.kscodes.micronaut.sample; import io.micronaut.test.extensions.junit5.annotation.MicronautTest; @MicronautTest public class SampleTest { // Add test cases here } |
2️⃣ src/test/resources/
- Holds any test-specific resources like alternative configurations.
Step 6 — How to Build and Run
Build the project:
./mvnw clean package
Run the application:
./mvnw mn:run
You can also run the JAR directly from the target/
folder after packaging.
Step 7 — Quick Recap
File/Folder | Purpose |
---|---|
pom.xml | Build configuration (Maven) |
mvnw | Maven wrapper |
Application.java | Application entry point |
application.yml | Micronaut configuration |
logback.xml | Logging configuration |
src/test/java | Unit tests |
Conclusion
The Micronaut project structure is very easy to understand once you break it down:
- Source code goes into
src/main/java
. - Configuration goes into
src/main/resources
. - Tests live inside
src/test/java
. - Build configuration stays inside
pom.xml
.
Even though Micronaut feels modern and powerful, it keeps things very developer-friendly and familiar — especially if you’ve used Maven or Java before.
Reference : Micronaut Docs