Bootstrap a Web Application with Micronaut

Overview

This tutorial illustrates how to bootstrap a web application with Micronaut. It shows the minimal configuration that is required to run a web application.

Dependencies

First, we'll need to add the micronaut-http-server-netty dependency, on top of the default required micronaut-runtime. This will provide our application with blocking as well as non-blocking http server and client implementations using netty.

<dependency>
    <groupId>io.micronaut</groupId>
    <artifactId>micronaut-http-server-netty</artifactId>
</dependency>
<dependency>
    <groupId>io.micronaut</groupId>
    <artifactId>micronaut-runtime</artifactId>
</dependency>

Creating a Micronaut Application

Starting a basic Micronaut application requires literally no configuration, not even an annotation.

public class MicronautWebApplication {
    public static void main(String[] args) {
        Micronaut.run(MicronautWebApplication.class);
    }
}

Conclusion

IDE Sidenote

If you're using an idea to run or debug your applications, you'll have to enable annotation processing in order for Micronaut to work.

Github Repository

This tutorial, alongside all of the upcoming tutorials related to JVM development can be found on github.

Karmahostage

Looking for an easy way to secure your application data using modern cryptography, visit Karmahostage to start your journey towards more secure applications!