1 Introduction

Micronaut is a modern, JVM-based, full stack Java framework designed for building modular, easily testable JVM applications with support for Java, Kotlin and the Groovy language.

Micronaut is developed by the creators of the Grails framework and takes inspiration from lessons learnt over the years building real-world applications from monoliths to microservices using Spring, Spring Boot and Grails.

Micronaut aims to provide all the tools necessary to build JVM applications including:

  • Dependency Injection and Inversion of Control (IoC)

  • Aspect Oriented Programming (AOP)

  • Sensible Defaults and Auto-Configuration

With Micronaut you can build Message-Driven Applications, Command Line Applications, HTTP Servers and more whilst for Microservices in particular Micronaut also provides:

  • Distributed Configuration

  • Service Discovery

  • HTTP Routing

  • Client-Side Load Balancing

At the same time Micronaut aims to avoid the downsides of frameworks like Spring, Spring Boot and Grails by providing:

  • Fast startup time

  • Reduced memory footprint

  • Minimal use of reflection

  • Minimal use of proxies

  • No runtime bytecode generation

  • Easy Unit Testing

Historically, frameworks such as Spring and Grails were not designed to run in scenarios such as server-less functions, Android apps, or low memory-footprint microservices. In contrast, Micronaut is designed to be suitable for all of these scenarios.

This goal is achieved through the use of Java’s annotation processors, which are usable on any JVM language that supports them, as well as an HTTP Server and Client built on Netty. In order to provide a similar programming model to Spring and Grails, these annotation processors precompile the necessary metadata in order to perform DI, define AOP proxies and configure your application to run in a low-memory environment.

Many of the APIs within Micronaut are heavily inspired by Spring and Grails. This is by design, and aids in bringing developers up to speed quickly.

1.1 What’s New?

Micronaut 2.2.0 includes the following changes:

Build Features

Maven Plugin Improvements

The Maven plugin now supports different <packaging> types:

  • jar (default): produces a runnable fat JAR.

  • native-image: generates a GraalVM native image.

  • docker: builds a Docker image with the application artifacts (compiled classes, resources, dependencies, etc).

  • docker-native: builds a Docker image with a GraalVM native image inside.

To package an application, mvn package is the one-stop shop to produce the desired artifact.

It also supports using mvn deploy as the only command required to deploy an application that, depending on the <packaging>:

  • jar (default): will deploy the artifact to a remote repository using org.apache.maven.plugins:maven-deploy-plugin:deploy.

  • docker or docker-native: will push the Docker image to the configured Docker registry.

Read more information in the Maven Plugin documentation.

Gradle Plugin Improvements

The Gradle plugin has a new testNativeImage task that builds the GraalVM Native Image and uses the native application as an embedded server enabling the ability to write native integration tests.

Micronaut Launch Enhancements

Support for Kotlin Gradle Builds

It is now possible to create applications that use build.gradle.kts instead of build.gradle using the --build argument of the CLI:

  1. $ mn create-app demo --build gradle_kotlin && cd demo
  2. $ ./gradlew test

Or via the Micronaut Launch API:

  1. $ curl https://launch.micronaut.io/demo.zip?build=gradle_kotlin -o demo.zip && unzip demo.zip -d demo && cd demo
  2. $ ./gradlew test

Push to Github

It is now possible to create an application with and Micronaut Launch and have it pushed automatically to a repository in your Github account. When generating an application just select the “Push to Github” option.

New Micronaut Modules

MQTT Support

Improving the experience in IoT use cases, Micronaut now has integration with MQTT similar to the integration with Kafka and RabbitMQ. See the Micronaut MQTT documentation to get started.

Micronaut Data R2DBC

A new module that adds support for R2DBC (Reactive Database Connectivity) has been added in preview status. Micronaut Data R2DBC lets you define reactive data repositories using R2DBC that work with any of the supported drivers and include support for GraalVM Native Image.

See the Documentation for Micronaut R2DBC for more information.

Module Upgrades

  • Micronaut Acme 2.1.0

  • Micronaut Aws 2.2.3

  • Micronaut Azure 2.1.0

  • Micronaut Cache 2.2.0

  • Micronaut Cassandra 3.1.0

  • Micronaut Data 2.2.0

  • Micronaut DiscoveryClient 2.2.0

  • Micronaut ElasticSearch 2.1.0

  • Micronaut Flyway 3.1.0

  • Micronaut Gcp 3.3.0

  • Micronaut GraphQL 2.2.0

  • Micronaut Groovy 2.2.0

  • Micronaut gRPC 2.2.0

  • Micronaut Hibernate Validator 3.0.0

  • Micronaut Jmx 2.1.0

  • Micronaut Kafka 3.1.0

  • Micronaut Kotlin 2.2.0

  • Micronaut Liquibase 3.0.0

  • Micronaut MQTT 1.0.0

  • Micronaut Micrometer 3.1.0

  • Micronaut Mongo 3.1.0

  • Micronaut NatsIo 2.2.0

  • Micronaut Neo4j 4.1.0

  • Micronaut OpenApi 2.2.0

  • Micronaut Oracle Cloud 1.1.0

  • Micronaut Picocli 3.1.0

  • Micronaut R2DBC 1.0.0.M2

  • Micronaut RabbitMQ 2.2.0

  • Micronaut Reactor 1.1.0

  • Micronaut Redis 3.1.0

  • Micronaut Rss 2.2.0

  • Micronaut Rss 2.3.0

  • Micronaut RxJava3 1.1.0

  • Micronaut Security 2.1.4

  • Micronaut Security 2.2.0

  • Micronaut Servlet 2.1.1

  • Micronaut Sql 3.3.1

  • Micronaut Test 2.2.1

  • Micronaut Views 2.1.0

  • Micronaut Xml 2.1.0

Dependency Upgrades

  • Caffeine 2.8.6

  • Eclipse Paho v3 1.2.5

  • Eclipse Paho v5 1.2.5

  • Elasticsearch 7.9.3

  • Flyway 7.0.4

  • gRPC 1.33.1

  • Hibernate 5.4.23.Final

  • Kafka 2.6.0

  • Kotlin Coroutines 1.4.1

  • Ktor 1.4.1

  • Liquibase 4.2.0

  • Lombok 1.18.16

  • Oracle JDBC Driver 19.8.0.0

  • Picocli 4.5.2

  • Protobuf 3.14.0

  • Reactor 3.4.0

  • Swagger 2.1.5

1.2 Upgrading to Micronaut 2.x

This section covers the steps required to upgrade a Micronaut 2.0 application to Micronaut 2.1.

New Group IDs

Some dependencies have new Maven Group IDs so you may need to update your dependency. The following table summarizes changes to group IDs:

Table 1. Updated Maven Group IDs
Previous IDNew ID

io.micronaut.configuration:micronaut-openapi

io.micronaut.openapi:micronaut-openapi

Mandatory upgrade for Netty tcnative

Due to a new SSL default value introduced in Netty 4.1.52, if you are using tcnative you need to update it to at least 2.0.33.Final.

Other Breaking Changes

If the above cases don’t cover your use case see the section on Breaking Changes for a list of other changes that are regarded as breaking in this release.