Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Micronaut 2.0 Enhances Tooling, Improves Support for Serverless and GraalVM

Micronaut 2.0 Enhances Tooling, Improves Support for Serverless and GraalVM

This item in japanese

Object Computing, Inc. (OCI) has formally released Micronaut 2.0, a major release of the full-stack JVM-based framework that helps create microservices-based, cloud-native and serverless applications utilizing languages such as Java, Groovy, and Kotlin.

This new release significantly upgrades the developer experience with the availability of Micronaut Launch, a completely revamped and faster Micronaut CLI, a new Maven plugin and upgrade to the Gradle version. It now supports Java 14, applications written in Groovy 3 and reactive frameworks including RxJava 3 and Reactor. Serverless capabilities have been expanded by adding support for Azure Functions and Google’s Cloud Functions. It also provides support for HTTP/2 and Servlets and a revamped security design. Finally, the new release provides improved performance with deeper integration with GraalVM, optimized memory consumption and improved startup times by up to 20% on an average across the entire framework.

Accorinding to Jeff Scott Brown, co-founder and director of the Micronaut Foundation, Grails and Micronaut practice lead at Object Computing:

"Micronaut 2.0 is another significant jump forward for Micronaut. We have expanded the reach of Micronaut by introducing runtime options including servlet support and even better GraalVM native image support. Our continued investments in serverless is being driven by user demand and is another important distinguisher for Micronaut."

Micronaut 2.0 includes a brand new starter service, Micronaut Launch, that helps scaffold Micronaut-based applications. Available both as a browser-based tool as well as a REST API, Launch helps to quickly scaffold and generate Micronaut-based applications. It also offers a preview of the generated application. The traditional Micronaut CLI has gone through a complete redesign with a focus on performance and efficiency using GraalVM native images. Micronaut Launch, a wrapper around Micronaut CLI, ensures interoperability.

Maven support has been upgraded to bring it to feature parity with the current Gradle feature set. A new Maven plugin is provided (mn:run) which helps run Micronaut applications via Maven with automatic recompilation and restart capabilities. In addition to this, Maven projects inherit from a new parent POM which configures the dependency management more cleanly.

The Gradle version has been upgraded to 6.5 which brings in incremental compilation support for Micronaut 2.0 projects. This essentially means that Micronaut does not have to run the complete annotation processors for every build.

Serverless support has been made more robust with the addition of Google Cloud Functions and Azure Functions while improving the feature set for AWS Lambda. Micronaut provides two approaches to help build serverless applications. The first approach defines a traditional Micronaut application and adds the corresponding serverless function feature to it (e.g., Cloud functions, Azure Functions or lambdas). Depending upon the chosen serverless platform, Micronaut will provide the necessary plumbing infrastructure to route function requests to the application.

The second approach defines a "serverless function" application type which enables developers to write direct low-level function code specific to the serverless function feature chosen (e.g., Google Cloud background functions that subscribe to pub-sub messages).

An example of a low-level serverless function written in Micronaut for the Google Cloud functions serverless platform is depicted below.

public class Function extends GoogleFunctionInitializer
        implements BackgroundFunction<PubSubMessage> {

    @Inject LoggingService loggingService;

    public void accept(PubSubMessage message, Context context) {

class PubSubMessage {
    String data;
    Map<String, String> attributes;
    String messageId;
    String publishTime;

Other features that have made their way to the new version include the capability to test functions locally utilizing the serverless platform provided SDKs which Micronaut includes as a dependency and GraalVM native image support for AWS SDK 2.

In addition to Netty, Micronaut 2.0 now adds support for embedded servlet runtimes (Jetty/Tomcat/Undertow). This enables developers to use traditional servlet-based features in their Micronaut applications. The experience of developing servlet-based Micronaut applications is the same as using Netty to include automatic recompilation/faster tests, etc. This also includes the capability to create GraalVM-based native images for the servlet-based uber jars.

An example of creating a servlet-based Micronaut application using the CLI and then running it is depicted below. This uses the jetty-server feature.

mn> create-app demo-servlet --features jetty-server

$ cd demo-servlet
$ ./gradlew run
org.eclipse.jetty.server.Server - Started @1219ms
io.micronaut.runtime.Micronaut - Startup completed in 615ms. Server Running: http://localhost:8080/

Micronaut 2.0 adds support for HTTP/2 and can be enabled using a simple change in the application.yml file for a Micronaut application. This support is currently available only for the Netty-based HTTP Server and client.

The configuration on the server side is depicted below.

	build-self-signed: true
	name: http2Demo
	http-version: http_2_0

The support for GraalVM native images has been moved out of experimental status and has now first class and expanded support across the framework, further solidifying the commitment towards GraalVM. This includes automatic configuration for static resources, JDBC drivers, Hibernate, Flyway, AWS SDK 2, and other areas.

Rate this Article