Micronaut is a modern, lightweight Java framework. Many developers love using VS Code because it’s free, fast, and full of useful extensions. In this guide, we will go step-by-step to set up Micronaut development in Visual Studio Code (VS Code) in a simple and beginner-friendly way.

Why Use Micronaut with VS Code?
- Lightweight IDE: Faster startup compared to heavy IDEs.
- Great extensions: Supports Java, Micronaut, debugging, and more.
- Cross-platform: Works on Windows, Mac, and Linux.
- Free and open-source
Combining Micronaut and VS Code makes microservice development smooth and efficient.
Prerequisites
Before starting, make sure you have:
- Java 21 JDK
- Micronaut CLI (Optional but useful)
- Visual Studio Code
Step 1: Install Required VS Code Extensions
Open VS Code and go to the Extensions panel (left sidebar).
Search and install these extensions:
| Extension Name | Purpose |
|---|---|
| Java Extension Pack | Provides Java support, debugging, Maven, Gradle |
| Micronaut Tools | Adds Micronaut-specific support |
| Gradle for Java | Gradle support for builds |
| Docker (optional) | If you plan to containerize apps |
You can also install the Java Extension Pack directly:
ext install vscjava.vscode-java-pack
Step 2: Create a New Micronaut Project
Using Micronaut Launch
- Go to Micronaut Launch.
- Choose:
- Generate and download the zip file.
- Extract it and open the folder in VS Code.
Using Micronaut CLI (optional)
If you installed Micronaut CLI:
mn create-app com.kscodes.micronautvscode --java-version 21
Open the generated folder in VS Code:
code com.kscodes.micronautvscode
Step 3: Configure Java in VS Code
VS Code should automatically detect Java. If not:
- Go to Settings > Java: Home.
- Set it to your Java 21 JDK path.
Step 4: Build and Run Your Micronaut App
Build with Gradle
Use the integrated terminal (Ctrl+`) in VS Code:
./gradlew build
Run the App
./gradlew run
Alternatively, you can use VS Code’s Run and Debug option for better control.
Step 5: Create Your First Controller
Let’s create a simple Hello World REST API.
File: src/main/java/com/kscodes/micronautvscode/HelloController.java
package com.kscodes.micronautvscode;
import io.micronaut.http.annotation.*;
@Controller("/hello")
public class HelloController {
@Get("/{name}")
public String sayHello(String name) {
return "Hello, " + name + "!";
}
}
Test it by opening:
http://localhost:8080/hello/World
You should see:
Hello, World!
Step 6: Debugging in VS Code
- Open the
Run and Debugpanel. - Click create a launch.json file.
- Select
Javaas environment. - VS Code will generate the config.
- Click Run to start debugging.
Step 7: Enable Virtual Threads (Java 21 Feature)
In application.yml:
micronaut:
executors:
io:
type: virtual
This allows Micronaut to use Java 21 virtual threads.
Step 8: Running Tests
Micronaut supports JUnit 5 out of the box.
File: src/test/java/com/kscodes/micronautvscode/HelloControllerTest.java
package com.kscodes.micronautvscode;
import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
import org.junit.jupiter.api.Test;
import jakarta.inject.Inject;
import io.micronaut.http.client.HttpClient;
import io.micronaut.http.client.annotation.Client;
import static org.junit.jupiter.api.Assertions.*;
@MicronautTest
class HelloControllerTest {
@Inject
@Client("/")
HttpClient client;
@Test
void testHelloEndpoint() {
String response = client.toBlocking().retrieve("/hello/World");
assertEquals("Hello, World!", response);
}
}
Run tests using VS Code’s Testing panel.
Summary
- Install Java 21, Micronaut CLI, and VS Code.
- Add Java and Micronaut extensions to VS Code.
- Create, build, run, and debug Micronaut apps directly inside VS Code.
- Leverage Java 21 features like virtual threads.
Useful Links
Stay tuned for more beginner-friendly Micronaut tutorials!