Support for JDK 14

    Micronaut has been updated to support JDK 14.

    Groovy 3

    Micronaut now supports applications written in Groovy 3.

    Startup Performance Improvements

    Startup time has been further improved in this release with typical startup time for a new application around 20% faster.

    Improvements to Bean Introspections

    Bean introspections have been improved to support static creator methods, interfaces and enums. This means you can define a bean introspection on an interface with a private implementation such as:

    Introspections on interfaces

    Support for Analyzing the Injection Point

    Micronaut’s Dependency Injection implementation has been improved such that you can now receive an InjectionPoint instance to any method. This makes it possible to customize how the bean is created based on the annotation metadata at the point at which the bean is injected.

    For example consider the following definition:

    1. @Inject @Client("http://foo.com") RxHttpClient client;

    A factory method can receive the injection point and create a client based off of the value:

    1. @Bean
    2. protected DefaultHttpClient httpClient(InjectionPoint<?> injectionPoint) {
    3. String url = metadata.stringValue(Client.class).orElse(null);
    4. if (url != null) {
    5. return new DefaultHttpClient(url);
    6. } else {
    7. return new DefaultHttpClient();
    8. }
    9. }

    Support for Eager Initialization of Beans

    Eager initialization of beans is useful in certain cases, such as on AWS Lambda where more CPU resources are assigned to Lamdba construction than execution. Therefore as for Micronaut 2.0, you can specify whether you want to eager initialization configuration or all singletons using the interface:

    Enabling Eager Initialization

    1. public class Application {
    2. public static void main(String[] args) {
    3. Micronaut.build(args)
    4. .eagerInitSingletons(true) (1)
    5. .mainClass(Application.class)
    6. .start();
    7. }
    8. }

    It is also possible to just eager init configuration using eagerInitConfiguration which will initialize all @ConfigurationProperties beans.

    Spot Bugs Instead of JSR-305 Nullable/NonNull Annotations

    In Micronaut 1.x the Google distributed JSR-305 annotations library (com.google.code.findbugs:jsr305) was used to specify @Nullable and @NonNull on interfaces of the Micronaut API using the annotations contained within the javax.annotation package.

    Due to the fact that JSR-305 has been cancelled and that this dependency has potential licensing issues (by using the javax namespace) as well as problems with the cross packages on Java 9+ with the module system Micronaut 2.x switches to the spotbugs-annotations module provided by the SpotBugs project.

    It is recommended users of Micronaut use this API instead (although the javax.annotation.Nullable and javax.annotation.NotNull annotations continue to be supported).

    CLI Features

    New Native CLI

    Micronaut’s mn command for the CLI has been rewritten in Micronaut itself and is now compiled into a native image .

    Micronaut Launch

    Create Micronaut 2.0 applications without having the CLI installed using curl:

    1. $ curl https://launch.micronaut.io/demo.zip -o demo.zip
    2. $ unzip demo.zip -d demo

    Or by visiting in your browser.

    Run curl [https://launch.micronaut.io](https://launch.micronaut.io) for more instructions on how to use the API or visit the OpenAPI documentation.

    Diff Command

    Run mn feature-diff --features=[FEATURE NAME] from the root of another Micronaut project to create a diff of the changes that need to be applied to enable the feature. For example:

    Using feature-diff

    1. $ mn feature-diff --features=azure-function
    2. --- micronaut-cli.yml
    3. +++ micronaut-cli.yml
    4. @@ -3,4 +3,4 @@
    5. testFramework: junit
    6. sourceLanguage: java
    7. buildTool: gradle
    8. -features: [app-name, application, gradle, http-client, java, junit, logback, netty-server, shade, yaml]
    9. +features: [app-name, application, azure-function, azure-function-http, gradle, java, junit, logback, yaml]
    10. --- host.json
    11. +++ host.json
    12. @@ -1,0 +1,7 @@
    13. +{
    14. + "version": "2.0",
    15. + "extensionBundle": {
    16. + "id": "Microsoft.Azure.Functions.ExtensionBundle",
    17. + "version": "[1.*, 2.0.0)"
    18. + }
    19. +}

    Micronaut’s support for GraalVM Native Image has been moved out of experimental status, which solidifies our commitment to continue improving support for native images.

    Automatic Static Resource Detection for Native Image

    It is not longer necessary to configure static resources for your Native Immage builds. The micronaut-graal annotation processor will automatically do this for you for all resources found in src/main/resources.

    Improved support for JDBC / Hibernate in Native Image

    It is no longer necessary to provide additional GraalVM related configuration to connect to databases via JDBC or Hibernate/JPA. Micronaut includes automatic support for the following drivers with GraalVM Native Image:

    • Oracle

    • MariaDB

    • MS SQL

    • H2

    • MySQL

    Support for Flyway Migrations in Native Image

    The Micronaut Flyway module has been so you can now run database migrations in Native Image.

    Support for Native Image in AWS SDK v2

    Version 2.0 of the Micronaut AWS module for the majority of the v2 AWS APIs including S3, Dynamo DB, SES, SNS, and SQS which will be helpful for those developing native AWS Lambda functions with Micronaut + GraalVM.

    Support for jOOQ in Native Image

    Support for Redis in Native Image

    The Micronaut Redis module includes support for Native Image. There are still some pending uses cases that won’t work because of how Lettuce driver works. Make sure you read the documentation.

    Support for Elasticsearch in Native Image

    The Micronaut Elasticsearch module includes support for Native Image

    Build Improvements

    New Maven Parent POM

    Micronaut now provides a new parent POM that can be used in Maven projects to get setup quickly:

    Using the Maven Parent POM

    New Maven Plugin

    The parent POM mentioned above includes a new Micronaut Maven Plugin that enables automatic application restart during development. Just run the following:

    1. $ ./mvnw mn:run

    Whenever you make a change to a class file the server will restart automatically.

    Gradle 6.5 Update

    For Gradle users who create new applications Gradle 6.5 is used which is compatible with JDK 14.

    Better Gradle Incremental Annotation Processing Support

    Gradle builds with Micronaut 2 for both Java and Kotlin should be significantly faster thanks to improved support for Gradle incremental annotation processing.

    Support for HTTP/2

    Micronaut’s Netty-based HTTP client and server have been updated to support HTTP/2.

    See the HTTP/2 documentation for more information on how to enable support for HTTP/2.

    Threading Model and Event Loop Group Improvements

    Micronaut 2.0 uses a new shared default Netty EventLoopGroup for server worker threads and client request threads. This reduces context switching and improves resource utilization.

    See the HTTP Client Configuration section for information on how to configure the default EventLoopGroup and add additional `EventLoopGroup’s that are configured per client.

    In addition, as of Micronaut 2.0 all operations are by default executed on the EventLoop and users can optionally use the new annotation to specify a named executor to execute an operation on if required (for example to offload blocking operations such as interactions with JPA/JDBC to a specific thread pool).

    Support for @RequestBean

    It is now possible to bind the properties of a POJO argument to a @Controller to request parameters, headers and so on using the annotation.

    Thanks to Github user asodja for this contribution.

    Micronaut Servlet

    Micronaut now includes support for creating Servlet applications and users can use the command line to create an application that targets popular Servlet containers:

    1. $ mn create-app myapp --features jetty-server # for Jetty
    2. $ mn create-app myapp --features tomcat-server # for Tomcat
    3. $ mn create-app myapp --features undertow-server # for Undertow

    Improved Support for Server-Side Content Negotiation

    Micronaut will now correctly handle the HTTP Accept header and pick the most appropriate route for the specified accepted media types using Server-Side Content Negotiation.

    Improved Support for Cloud Foundry

    Micronaut will now process the VCAP_APPLICATION and VCAP_SERVICES environment variables and treat them as property sources.

    Thanks to Fabian Nonnenmacher for this contribution.

    HTTP Client Improvements

    It is no longer necessary to use @Client(..) to inject a default RxHttpClient instance. You can now inject the default client simply with:

    1. @Inject RxHttpClient client;

    If no host is provided at the time of a request, a will be thrown.

    API for Proxying Requests

    A new API for writing API gateways and proxying requests has been added. See the documentation on the for more information.

    Endpoint Sensitivity

    It is now possible to control the sensitivity of individual endpoint methods. The annotation can be applied to endpoint methods to allow for some methods to have a different sensitivity than the value supplied to the endpoint annotation.

    Improvements to Instrumentation

    The Instrumentation mechanism for RxJava 2 has been improved to address issues with MDC and reduce the size of reactive stack traces. Thanks to and Lajos Gathy for their contributions in this area.

    Kotlin Improvements

    Support for KTOR in Micronaut Launch

    You can generate a Micronaut + application from Micronaut Launch or via the command line.

    Micronaut Kotlin Extensions

    New Kotlin Extension Functions are available that make the Kotlin + Micronaut experience that little bit better.

    Support for Google Cloud Function

    You can now write Serverless functions that target Google Cloud Function using Micronaut. See the Micronaut GCP documentation and for more information.

    Support for Microsoft Azure Function

    You can now write Serverless functions that target Microsoft Azure using Micronaut. See the documentation and example application for more information.

    Improvements to Micronaut AWS

    Micronaut AWS 2.0.0 includes a number of improvements to support for AWS Lambda and AWS in general including new client modules for AWS SDK 2.0, cold start improvements on Lambda and improvements to the support for Amazon Alexa.

    Module Improvements

    Micronaut is more modular than ever, with several components now available in separate modules and upgrades to those modules.

    Micronaut Cache 2.0.0 Upgrade

    Caching has been moved into a separate module and out of micronaut-runtime. If you need caching (including the annotations within io.micronaut.cache.annotation) you just need to add the individual module for the cache provider you are interested (for example Caffeine, Redis, Hazelcast etc.).

    Micronaut SQL 2.3.0 Upgrade

    Micronaut SQL has been improved to default to Micronaut transaction management (making Spring management optional) and includes support for Jdbi (Thanks to for this contribution).

    In addition, support has been added for Oracle Universal Connection Pool. Thanks to for this contribution.

    Micronaut Security 2.0.0 Upgrade

    The security module has seen many changes to improve the API and introduce new features to support a wider array of use cases.

    See the for more information.

    New Reactive Modules

    Whilst RxJava 2 remains the default, individual modules for other reactive libraries have been added.

    For RxJava 3:

    1. implementation("io.micronaut.rxjava3:micronaut-rxjava3")
    1. <dependency>
    2. <groupId>io.micronaut.rxjava3</groupId>
    3. <artifactId>micronaut-rxjava3</artifactId>
    4. </dependency>

    For Reactor:

    1. <dependency>
    2. <groupId>io.micronaut.reactor</groupId>
    3. <artifactId>micronaut-reactor</artifactId>
    4. </dependency>

    And legacy support for RxJava 1:

    1. implementation("io.micronaut.rxjava1:micronaut-rxjava1")
    1. <dependency>
    2. <groupId>io.micronaut.rxjava1</groupId>
    3. <artifactId>micronaut-rxjava1</artifactId>
    4. </dependency>

    Included within the new RxJava 3 and Reactor modules are variants of called and ReactorHttpClient respectively.

    To use the RxJava 3 HTTP client add the following dependency:

    1. implementation("io.micronaut.rxjava3:micronaut-rxjava3-http-client")
    1. <dependency>
    2. <groupId>io.micronaut.rxjava3</groupId>
    3. <artifactId>micronaut-rxjava3-http-client</artifactId>
    4. </dependency>

    To use the Reactor HTTP client add:

    1. <dependency>
    2. <groupId>io.micronaut.rxjava3</groupId>
    3. <artifactId>micronaut-reactor-http-client</artifactId>
    4. </dependency>

    New Micronaut NATS module

    A new messaging module for has been included in Micronaut core.

    See the documentation for Micronaut Nats for more information.

    Thanks to for this contribution.

    Module Upgrades

    • Micronaut AWS - 1.3.92.0.0.RC1

    • Micronaut Cache - 1.2.02.0.0.RC1

    • Micronaut Data - 1.0.21.1.0.RC2

    • Micronaut GCP - 1.1.02.0.0.RC2

    • Micronaut gRPC - 1.1.12.0.0.RC1

    • Micronaut Micrometer - 1.3.12.0.0.RC2

    • Micronaut Mongo - 1.3.02.1.0

    • Micronaut Neo4j - 1.3.03.0.0.RC1

    • Micronaut SQL - 1.3.02.3.0

    • Micronaut Security - 1.4.02.0.0.RC1

    • Micronaut Spring - 1.0.22.0.1

    Dependency Upgrades

    • Hibernate 5.4.10.Final5.4.16.Final

    • Groovy 2.5.83.0.3

    • Mongo Reactive Streams 1.13.04.0.2

    • Mongo Java Driver 3.12.04.0.2

    • Jaeger 1.0.01.2.0