Micronaut® Blog

Micronaut 2.1 Released!

By Jason Schindler

October 5, 2020

Tags: #release #micronaut2 #gradle #gcp #oracle #kotlin #docker #graalvm

We are pleased to announce the release of Micronaut 2.1! It includes support for Kotlin 1.4, KoTest, Oracle Cloud Functions, Google Pub/Sub, and a number of other enhancements. This release also includes a brand-new Gradle plugin with a host of features for building Docker and GraalVM Native Images!

New Gradle Plugin

Micronaut's new Gradle plugin includes first-class support for Docker and GraalVM Native Images. It also makes it easy to configure your Micronaut runtime environment and build your application as a layered JAR.

Here is a sample configuration:

plugins {
     id 'io.micronaut.application' version '{version}'
}
repositories {
    jcenter()
    mavenCentral()
}

micronaut {
    version = "2.1.0" // The Micronaut Version
    runtime "netty" // Using the Netty runtime
}
mainClassName = "example.Application" // Your main class

This application will be built with dependencies for the Netty runtime. Other runtime configurations are available including Tomcat, Jetty, Google Cloud Function, and Oracle Cloud Function.

The Gradle plugin integrates with the Gradle Docker Plugin, and you can build a Docker image using a layered jar by running:

./gradlew dockerBuild

If you would like to build a Docker image using a GraalVM Native Image, you can run:

./gradlew dockerBuildNative

For a full list of supported runtimes and tasks, see the documentation.

New Cloud Features

Micronaut 2.1 adds improvements for Oracle Cloud and Google Cloud Platform.

Oracle Functions

With Micronaut 2.1, you can create Oracle Function projects by adding the oracle-function feature to a new project in Micronaut Launch or by passing it to the Micronaut CLI:

mn create-function-app myfunction --features oracle-function

After some configuration updates, you can push your application image to the Oracle Container Registry using ./gradlew dockerPush or ./gradlew dockerPushNative.

See the Micronaut Oracle Cloud Guide for more details.

Google Cloud Platform Enhancements

Thanks to some amazing contributions from Vinicius Carvalho, our Google Cloud Platform (GCP) support has received some enhancements.

First, the Micronaut GCP configuration now includes Logging Support with the new StackdriverJsonLayout class that formats log output to use the Stackdriver structured format. When used with Stackdriver Trace, entries include a traceId to correlate traces to log entries.

Micronaut 2.1 also includes support for Google Cloud Pub/Sub messaging! Once you have configured your Topics and Subscriptions in GCP, you can use them from your Micronaut applications by using the @PubSubClient annotation on an interface to create a publisher, and the @PubSubListener annotation on a class to set up subscriptions.

For more information about Micronaut's GCP support, see the Micronaut GCP Guide.

Give it a Try!

The easiest way to create a new Micronaut 2.1 application is with Micronaut Launch. Just select the application type, build, and features you would like to use and generate a new Micronaut application configured just for you! You can also use the Micronaut CLI to create and manage your Micronaut applications. For more information and installation options, please see the Download page.

For Micronaut Documentation, Guides, and API information see the Documentation.

To learn more about using Micronaut, check out these learning resources!

Thank You!

This release would not have been possible without the contributions and support of the amazing Micronaut community! Thank you to all that have contributed time, effort, and energy to making Micronaut a world-class framework for developing applications on the JVM.

We would also like to thank the Technical Advisory Board, Board of Directors, and Contributing Members of the Micronaut Foundation. The Micronaut Foundation is a not-for-profit organization that exists to support and collectively lead the open source Micronaut project. In particular, we would like to thank Object Computing for its significant sponsorship and continued stewardship of the Micronaut Framework.