Micronaut : The starting your first project
Calling Super Heroes With Faker and Micronaut

I am a developer who loves Java, Spring, Quarkus, Micronaut, Open source, Microservices, Cloud
Search for a command to run...
Calling Super Heroes With Faker and Micronaut

I am a developer who loves Java, Spring, Quarkus, Micronaut, Open source, Microservices, Cloud
No comments yet. Be the first to comment.
Micronaut is one of the promising java based frameworks in the Microservices space. Here is a series that I have started on Microservices framework based on Micronaut.
In last section we saw , how easy it was to create a project with micronaut. We created our universe savior heroes and called them through our url /super-heroes with their powers .If you have not checked it, you can take a look at below link. https:...
Spring AI Tool Calling: From Chatbot to AI Agent with @Tool Your AI is smart. It knows an enormous amount. But it's frozen. It doesn't know what time it is right now. It doesn't know what's on your ca
Spring AI Advisors API Explained Series: Spring AI Complete Course — Lecture 4 of 12Reading Time: 8 minutesLevel: Intermediate Most developers stop at ChatClient. That is enough for demos. It is not
Working with Multiple AI Models in Spring AI Spring AI Complete Course — Lecture 3 of 12Previous: Lecture 2 — ChatClient API | Next: Lecture 4 — Advisors API In production AI applications, you rarel
Spring AI ChatClient API: The Fluent Heart of AI Integration Introduction If you've ever tried integrating AI models into a Java application, you know the pain. HTTP clients, API keys scattered everywhere, vendor-specific SDKs that never quite fit. W...
What is Spring AI? — Why Java Developers Need This in 2026 Every AI tutorial you see is in Python. LangChain, LlamaIndex, OpenAI SDK — all Python. But here's the uncomfortable truth: 80% of enterprise backends run Java. So who's building AI into thos...
Micronaut is one of the java framework which can be used to create a Java microservices which are fast, reliable , modular and testable. You can also create serverless application with micronaut. If you have ever worked with Spring or any other java based web framework, you will find very less learning curve with it.
Let's explore micronaut in this series.
The goal of this article is simple. Create a Hello world kind of application with micronaut. The application should build and start . We will also create a custom (GET) endpoint to see it working . Our endpoint will use Faker lib to fake to create fake superheros and return to us.
We require
There are several ways to start the new project , you can use the launcher website or initializer using cmd I will be using launcher website for this article. Visit https://micronaut.io/launch/ .
I am using maven as build tool and java 16 as jdk version. It depends on you if you want to use other tools and jdk version.
I have also changed the application name as super-heroes and base package as com.codingsaint

Click on generate the project. It will download the zip version on your local maching. Unzip the file and open in folder / pom in your favorite IDE. I am using intelliJ for it.
To run the project , you can simply open the terminal and type
./mvnw mn:run
This will download the dependency and start the project on 8080 .

You can check http://localhost:8080
Java Faker lib will help us to create fake super hero names. The goal is to create 10 fake super heroes with their special power . When we hit /super-heros endpoint we should retrieve the our super heroes.
Add the below dependency in pom file. The terminal in which you started the project will show logs of download dependency (if not present) . The application will be restarted for better developer experience.
<dependency>
<groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId>
<version>1.0.2</version>
</dependency>
Create a SuperHeroController.java class. Annotate it with @Controller ,and use faker to create fake super heroes for us.
Below is the code for same
package com.codingsaint;
import com.github.javafaker.Faker;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@Controller
public class SuperHeroController {
@Get("super-heroes")
public Collection<String> superheroes(){
Faker fake = new Faker();
List<String> superHeros= new ArrayList<>();
for (int i = 0; i < 10; i++) {
var superHero=fake.superhero();
superHeros.add(superHero.name()+" - "+superHero.power());
}
return superHeros;
}
}
Hit http://localhost:8080/super-heroes , you will get super charged super heroes with their world saving powers as a response.
[
"General Storm Boy - Physical Anomaly",
"Magnificent Rachel Pirzad Eyes - Atmokinesis",
"Doctor Hawk Lord - Biokinesis",
"Magnificent Ink I - Toxikinesis",
"Arclight - Atmokinesis",
"Sobek - Empathy",
"Isis Dragon - Telekinesis",
"Cyborg Quantum - Levitation",
"Captain Hawk Man - Hypnokinesis",
"Mr Titan - Cloaking"
]
As Faker magic , you will generate new super heros every time you want.
It is super easy to create a simple REST project with micronaut. While there are other great frameworks who are equally good, micronaut seems exciting as well . It is now backed by oracle so we can be optimistic to see smooth progress in the framework as well.
If you like my articles you can support me by sharing the articles with your friends, twitter, facebook or any other social media. You can also buy me a coffee