Table of Contents

Micronaut Upgrade

Upgrade to Micronaut Framework 4.0

Upgrade your Micronaut applications with the OpenRewrite integration for Gradle and Maven.

Breaking Changes

You can find more details in the link: What’s new and breaking changes sections of the Micronaut Framework 4.0.

Micronaut Framework 3.9.0

3.9.0 Breaking Changes

Since Micronaut Framework 3.9.0, CORS allowed-origins configuration does not support regular expressions to prevent accidentally exposing your API. You can use allowed-origins-regex, if you wish to support a regular expression.

Micronaut Framework 3.8.7

3.8.7 Breaking Changes

Micronaut Framework 3.8.7 updates to SnakeYAML 2.0 which addresses CVE-2022-1471. Many organizations' policies forbid their teams to use Micronaut Framework if the framework depends on a vulnerable dependency, even if the framework is unaffected. Micronaut Framework is not affected by CVE-2022-1471. Micronaut Framework uses SnakeYAML to load configuration in Micronaut applications. There is only one instance of SnakeYAML instantiation which uses the Safe Constructor. Using SnakeYaml’s SafeConstructor which is the recommended way to prevent this issue:

We recommend using SnakeYaml’s SafeConsturctor when parsing untrusted content to restrict deserialization.

Micronaut Framework 3.8.0

What’s new with 3.8.0

Key features:

  • GraalVM 22.3 Support

  • With Micronaut 3.8.0, you can use @RequestBean annotations with Records. Before 3.8.0, you could use a POJO as a controller method parameter and annotate the parameter with @RequestBean to bind any Bindable value (e.g., HttpRequest, @PathVariable, @QueryValue or @Header fields).

  • If you enable CORS from any origin while running your app in localhost (e.g., test or development), since 3.8.0, the CorsFilter returns 403 for non-localhost origins to protect you against drive-by localhost attacks.

Please read the Micronaut Framework 3.8.0 announcement blog post. You will find a detailed overview of what’s new in Micronaut 3.8.0.

Micronaut Framework 3.7.0

What’s new with 3.7.0

Several improvements:

  • If you want complete control of where your application loads configuration from, for example, due to security restrictions, you can disable the default PropertySourceLoader implementations by calling ApplicationContextBuilder::enableDefaultPropertySources(false) when starting your application.

  • Better java.time conversion for YAML configuration

  • Client SSL inner configuration is Bootstrap context compatible.

  • UriBuilder methods queryParam and replaceQueryParam ignore null values.

  • It is possible to stop the Netty server without stopping the Application context.

  • You can declare beans at runtime using interfaces.

  • You can mark static methods as @Executable.

  • A big HTTP client refactor.

Spring integration improvements

  • Micronaut Spring contains improvements for developers who want to use Micronaut modules with a Spring application or consume Spring libraries from a Micronaut application.

New modules:

Please read the Micronaut Framework 3.7.0 announcement blog post. You will find a detailed overview of what’s new in Micronaut 3.7.0.

Micronaut Framework 3.6.0

What’s new with 3.6.0

Key features:

Please read the Micronaut Framework 3.6.0 announcement blog post. You will find a detailed overview of what’s new in Micronaut 3.6.0.

Micronaut Core features:

Don’t apply a @Filter for services

It is possible to exclude services from an HTTP Client Filter with the member excludeServiceId of @Filter.

@Filter(patterns = '/**', excludeServiceId = 'authClient')
public class AppHttpClientFilter implements HttpClientFilter {

Netty runtime

This version upgrades Netty from 4.1.77 to 4.1.79. Moreover, it contains improvements to the API to configure the Netty Client Pipeline and to configure the Netty Server Pipeline.

Improvements to HttpClientException

If present a serviceId field is populated in the HttpClientException and shown in the exception message.

Modules Upgrades

  • Micronaut AWS 3.5.3 to 3.7.0

  • Micronaut Azure 3.2.3 to 3.3.0

  • Micronaut Cache 3.4.1 to 3.5.0

  • Micronaut Cassandra 4.0.0 to 5.1.1

  • Micronaut Coherence 3.4.1 to 3.5.1

  • Micronaut Data 3.4.3 to 3.7.2

  • Micronaut Elasticsearch 4.2.0 to 4.3.0

  • Micronaut Email 1.2.3 to 1.3.1

  • Micronaut Flyway 5.3.0 to 5.4.0

  • Micronaut GCP 4.2.1 to 4.4.0

  • Micronaut GraphQL 3.0.0 to 3.1.0

  • Micronaut Groovy 3.1.0 to 3.2.0

  • Micronaut JaxRS 3.3.0 to 3.4.0

  • Micronaut JMX 3.0.0 to 3.1.0

  • Micronaut Kafka 4.3.1 to 4.4.0

  • Micronaut Micrometer 4.3.0 to 4.4.0

  • Micronaut Microstream 1.0.0-M1 to 1.0.0

  • Micronaut Liquibase 5.3.0 to 5.4.1

  • Micronaut Mongo 4.2.0 to 4.4.0

  • Micronaut Neo4J 5.0.0 to 5.1.0

  • Micronaut Nats 3.0.0 to 3.1.0

  • Micronaut OpenAPI 4.2.2 to 4.4.3

  • Micronaut Picocli 4.2.1 to 4.3.0

  • Micronaut Problem 2.3.1 to 2.4.0

  • Micronaut RabbitMQ 3.1.0 to 3.3.0

  • Micronaut R2DBC 3.0.0 to 3.0.1

  • Micronaut Reactor 2.2.3 to 2.3.1

  • Micronaut Redis 5.2.0 to 5.3.0

  • Micronaut RxJava3 2.2.1 to 2.3.0

  • Micronaut Serialization 1.1.1 to 1.3.0

  • Micronaut Servlet 3.2.3 to 3.3.0

  • Micronaut Spring 4.1.1 to 4.2.1

  • Micronaut SQL 4.4.1 to 4.6.3

  • Micronaut Test 3.3.1 to 3.4.0

  • Micronaut TOML 1.0.0 to 1.1.1

  • Micronaut Tracing 4.1.1 to 4.2.1

  • Micronaut Views 3.4.0 to 3.5.0

  • Micronaut Jackson XML 3.0.1 to 3.1.0

Micronaut Framework 3.5.0

What’s new with 3.5.0

GraalVM 22.1.0

Micronaut framework 3.5 supports GraalVM 22.1.0.

Incremental Compilation for Gradle Builds

Micronaut framework 3.5 supports fully incremental compilation, including GraalVM metadata for Gradle Builds.

Micronaut Data

  • Postgres enums for JDBC.

  • Pagination for reactive repositories and specifications.

  • Pagination for async, coroutines repositories, and specifications.

Turbo Integration

Micronaut Views adds integration with Turbo

New Module - Micronaut Microstream

Micronaut Microstream eases working with MicroStream, a native Java object graph storage engine.

@Scheduled with Time Zones

Optionally, you can specify a time zone when using the @Scheduled annotation.

@Scheduled(cron = '1/33 0/1 * 1/1 * ?', zoneId = "America/Chicago")
void runCron() {
...
..

Support validation groups with @Validated

You can enforce a subset of constraints using validation groups using groups on the @Validated.

Advanced Listener Configuration

Micronaut framework 3.5.0 offers more flexibility in configuring the HTTP Server. Instead of configuring a single port, you can specify each listener manually.

EPHEMERAL FACTORIES

A Factory has the default scope @Singleton, and it is destroyed with the context. Since Micronaut framework v3.5.0, you can dispose of the factory after producing a bean by annotating your factory class with @Prototype and @Factory

Module upgrades

Several modules publish a BOM (Bill of Materials) or use a Gradle Version Catalogs:

Schema Migration Modules

Micronaut Framework 3.4.0

What’s new with 3.4.0

Localized Message Source

You can now inject LocalizedMessageSource, a @RequestScope bean, in your controllers to resolve localized messages for the current HTTP Request. It works in combination with Micronaut Locale Resolution capabilities.

Referencing bean properties in @Requires.

@Requires(bean=Config.class, beanProperty="foo", value="John")

Micronaut Data MongoDB

Micronaut AOT and Maven

Micronaut AOT is now fully supported for Maven users. Enabling AOT is as simply as passing -Dmicronaut.aot.enabled when running, testing, or packaging your application.

For more details, check the Micronaut Maven Plugin documentation.

Micronaut TOML

Micronaut TOML allows you to write your application configuration with TOML in addition to Properties, YAML, Groovy or Config4k.

Micronaut Security

Micronaut Security 3.4.1 responds with an error when an authenticated user visits a sensitive endpoint. This forces the developer to define how they want their application to behave in that scenario. Read the release notes and the documentation to learn more.

BOM Modules

Several projects include a BOM (Bills of Materials) module:

Other Module Upgrades

Micronaut Framework 3.3.0

What’s new with 3.3.0

GraalVM 22.0.0.2

Micronaut now supports the latest GraalVM 22.0.0.2 release.

Environment Endpoint

A new API api:management.endpoint.env.EnvironmentEndpointFilter[] has been created to allow applications to customize which keys should have their values masked and which keys should not have their values masked. See the documentation for full details.

AOP Interceptor Binding

When binding an AOP annotation to an interceptor, only the presence of the annotation is used to determine if the interceptor should be applied. Now it’s possible to also bind based on the values of the annotation. To enable this feature, set the bindMembers member of the ann:aop.InterceptorBinding[] annotation to true.

Netty Buffer Allocation

It is now possible to configure the default Netty buffer allocator. See the configuration reference.

Improved Flexibility in Class Style

Many features of the Micronaut framework rely on the convention of getters and setters. Due to things like records and builders, the method names we look for are now configurable with the ann:core.annotation.AccessorsStyle[] annotation. For example, the annotation can be placed on ann:context.annotation.ConfigurationProperties[] beans to allow for binding configuration to methods that do not begin with set. It can also be used with classes annotated with ann:core.annotation.Introspected[].

Access Log Exclusions

The Netty access logger now supports excluding requests based on a set of regular expression patterns that match against the URI. See the AccessLogger documentation.

New Serialization/Deserialization Module

Micronaut Serialization is a new module created as an alternative to Jackson. It supports serializing and deserializing Java types (including Java 17 records) to and from JSON and other formats.

Users now have the choice of an alternative implementation that’s largely compatible with existing Jackson annotations but contains many benefits, including the elimination of reflection, compile-time validation, greater security because only explicit types are serializable, and reduction of native image build sizes, build times, and memory usage.

New Email Module

Micronaut Email is a new module to ease sending emails from a Micronaut application. It provides integration with transactional email providers such as Amazon Simple Email Service, Postmark, Mailjet or SendGrid.

Micronaut AOT

During this minor cycle, we released a milestone release of a new module Micronaut AOT. You can use Micronaut AOT and use the build-time optimizations provided by the module to achieve faster startup times via the Micronaut Gradle Plugin. Please, read more about it in the announcement blog post.

Micronaut Kubernetes 3.3.0

Micronaut Kubernetes 3.3 adds support to easily create the Kubernetes Operator. The Kubernetes Operator is a known pattern used to extend the capabilities of Kubernetes by creating application specific controllers for both native and custom resources. See more on Kubernetes Operator.

The version of Micronaut Kubernetes 3.3.0 also adds new Kubernetes reactive client for RxJava3.

Other Module Upgrades

  • Micronaut Cache 3.1.0

  • Micronaut Discovery Client 3.1.0

  • Micronaut Elasticsearch 4.2.0

  • Micronaut Flyway 5.1.1

  • Micronaut Kafka 4.1.1

  • Micronaut Kotlin 3.1.0

  • Micronaut Liquibase 5.1.1

  • Micronaut Openapi 4.0.0

  • Micronaut Picocli 4.1.0

  • Micronaut Problem 2.2.0

  • Micronaut Security 3.3.0

  • Micronaut Sql 4.1.1

  • Micronaut Toml 1.0.0-M2

  • Micronaut Views 3.1.2

Other Dependency Upgrades

  • Apache Commons DBCP 2.9.0

  • Elasticsearch 7.16.3

  • Flyway 8.4.2

  • Hibernate 5.5.9.Final

  • Kotlin 1.6.10

  • Liquibase 4.7.1

  • Logback 1.2.10

  • Swagger 2.1.12

3.3.0 Breaking Changes

endpoints:
  env:
    enabled: true

This will then be available, but mask all values. To restore the previous functionality, you can add a bean that implements api:management.endpoint.env.EnvironmentEndpointFilter[]:

Legacy Environment Filtering Bean
@Singleton
public class LegacyEnvEndpointFilter implements EnvironmentEndpointFilter {
    @Override
    public void specifyFiltering(@NotNull EnvironmentFilterSpecification specification) {
        specification.legacyMasking();
    }
}

See the documentation for more filtering options.

Micronaut Framework 3.2.4

3.2.4 Breaking Changes

Micronaut Framework 3.2.0

What’s new with 3.2.0

GraalVM 21.3.0

Micronaut has been updated to support the latest GraalVM 21.3.0 release. Please keep in mind that starting with 21.3.0 GraalVM doesn’t release a version based on JDK 8. If you still use Java 8 use the GraalVM JDK 11 distribution.

The official GraalVM Maven plugin has new GAV coordinates so if you have declared it in your pom.xml update the coordinates to:

<plugin>
    <groupId>org.graalvm.buildtools</groupId>
    <artifactId>native-maven-plugin</artifactId>
...
</plugin>

Please check the official documentation about how to customize the plugin.

Gradle Plugin 3.0.0

A new major version of the Gradle plugin has been released, including internal changes to use Gradle’s lazy configuration APIs. In the process, documentation has been rewritten.

Support for GraalVM now delegates to the official GraalVM plugin. We recommend to upgrade in order to get the latest bugfixes, but this constitutes a breaking change for some users:

  • the nativeImage task is now replaced with nativeCompile

  • native image configuration happens in the graalvmNative DSL extension instead of the nativeCompile task

  • native image building makes use of Gradle’s toolchain support. Please refer to the documentation for help.

Note
You can still build existing applications or libraries using the 2.x version of the Gradle plugin. Documentation for this version can be found here.

Kotlin 1.6.0

Micronaut 3.2.0 includes support for Kotlin 1.6.0.

HTTP Features

WebSocket Ping API

WebSocket ann:websocket.annotation.OnMessage[] methods can now accept a api:websocket.WebSocketPongMessage[] parameter that will receive a WebSocket pong sent as a response to a ping submitted using the new sendPingAsync method on api:websocket.WebSocketSession[].

HTTP2 Server Push

It is now possible to send resources, e.g. stylesheets required by a HTML page, to the client alongside the request for the page using the HTTP2 server push protocol. See the HTTP/2 documentation for information on how to use this feature.

JsonView on request bodies

You can now specify the Jackson @JsonView annotation on @Body parameters to controller methods.

WebSocket ws/wss protocol support

The WebSocket clients now support the ws/wss protocol. To implement this change, the api:websocket.WebSocketClient[] create methods now take a URI instead of a URL. The URL methods have been deprecated.

Note: Should you be calling WebSocketClient.create(null), the method call is now ambiguous. Insert a cast in that case: WebSocketClient.create((URI) null)

SSL handshake timeout configuration

The SSL handshake timeout can now be configured using the micronaut.ssl.handshakeTimeout and micronaut.http.client.ssl.handshakeTimeout configurations for the server and client respectively.

Module Upgrades

Micronaut Data 3.2.0
  • Repositories with JPA Criteria API specification for Micronaut JDBC/R2DBC

  • Expandable query parameters optimizations

Reactive Modules
  • The RxJava2, RxJava3, and Reactor modules have been updated with the equivalent static create methods on their core counterparts.

Micronaut Micrometer 4.1.0
  • Adds support for metrics with gRPC

Micronaut Security 3.2.0
  • The way JSON Web Key Sets are being cached has been greatly improved for scenarios where there are multiple key sets.

Other Module Upgrades
  • Elasticsearch 7.15.2

  • Flyway 8.0.2

  • gRPC 1.39.0

  • Liquibase 4.6.1

  • Micronaut Elasticsearch 4.0.0

  • Micronaut Flyway 5.0.0

  • Micronaut gRPC 3.1.1

  • Micronaut Liquibase 5.0.0

  • Micronaut OpenAPI 3.2.0

  • Micronaut Redis 5.1.0

  • Testcontainers 1.16.1

3.2.0 Breaking Changes

  • The HTTP client now does SSL certificate verification by default. The old insecure behavior can be re-enabled by setting the micronaut.http.client.ssl.insecureTrustAllCertificates property to true, but consider using a trust store instead if you’re using self-signed certificates.

  • Maven GraalVM Native Image plugin has new GAV coordinates. If you have declared it in your pom.xml please update the coordinates to:

<plugin>
    <groupId>org.graalvm.buildtools</groupId>
    <artifactId>native-maven-plugin</artifactId>
...
</plugin>
  • WebSocketClient.create has been modified to accept a URI parameter instead of URL. The old URL methods still exist, but when called with null like WebSocketClient.create(null), the method call is now ambiguous. Please insert a cast to URI: WebSocketClient.create((URI) null). The same applies for the create method that accepts an additional HttpClientConfiguration parameter.

Micronaut Framework 3.1.0

What’s new with 3.1.0

Core Features

Primitive Beans

Factory Beans can now create beans that are primitive types or primitive array types.

See the section on Primitive Beans and Arrays in the documentation for more information.

Repeatable Qualifiers

Qualifiers can now be repeatable (an annotation annotated with java.lang.annotation.Repeatable) allowing narrowing bean resolution by a complete or partial match of the qualifiers declared on the injection point.

InjectScope

A new ann:context.annotation.InjectScope[] annotation has been added which destroys any beans with no defined scope and injected into a method or constructor annotated with @Inject after the method or constructor completes.

More Build Time Optimizations

Further build time metadata optimizations have been added included reducing the number and size of the classes generated to support Bean Introspection and including knowledge of repeatable annotations in generated metadata avoiding further reflective calls and optimizing Micronaut’s memory usage, in particular with GraalVM.

Improvements to Context Propagation

Support for Reactive context propagation has been further improved by inclusion of request context information in the Reactor context and documentation on how to effectively propagate the context across reactive flows when using Kotlin coroutines.

Improvements to the Element API

The build-time api:inject.ast.Element[] API has been improved in a number of ways:

  • New methods were added to the api:inject.ast.MethodElement[] API to resolve the retriever type and throws declaration

  • A new experimental API has been added to the api:inject.ast.ClassElement[] API to resolve generic placeholders and resolve the generic bound to the element

HTTP Features

Filter By Regex

HTTP filters now support matching URLs by a regular expression. Set the patternStyle member of the annotation to REGEX and the value will be treated as a regular expression.

Random Port Binding

The way the server binds to random ports has improved and should result in fewer port binding exceptions in tests.

Client Data Formatting

The ann:core.convert.format.Format[] annotation now supports several new values that can be used in conjunction with the declarative HTTP client to support formatting data in several new ways. See the client parameters documentation for more information.

StreamingFileUpload

The api:http.multipart.StreamingFileUpload[] API has been improved to support streaming directly to an output stream. As with the other transferTo methods, the write to the stream is offloaded to the IO pool automatically.

Server SSL Configuration

The SSL configuration for the Netty server now responds to refresh events. This allows for swapping out certificates without having to restart the server. See the https documentation for information on how to trigger the refresh.

New Netty Server API

If you wish to programmatically start additional Netty servers on different ports with potentially different configurations, new APIs have been added to do so including a new api:http.server.netty.NettyEmbeddedServerFactory[] interface.

See the documentation on Starting Secondary Servers for more information.

Deprecations

The netty.responses.file.* configuration is deprecated in favor of micronaut.server.netty.responses.file.*. The old configuration key will be removed in the next major version of the framework.

Module Upgrades

Micronaut Data 3.1.0
  • Kotlin’s coroutines support. New repository interface CoroutineCrudRepository.

  • Support for AttributeConverter

  • R2DBC upgraded to Arabba-SR11

  • JPA Criteria specifications

Micronaut JAX-RS 3.1

The JAX-RS module now integrated with Micronaut Security allowing binding of the JAX-RS SecurityContext

Micronaut Kubernetes 3.1.0

Micronaut Kubernetes 3.1 introduces new annotation @Informer. By using the annotation on the ResourceEventHandler the Micronaut will instantiate the SharedInformer from the official Kubernetes Java SDK. Then you only need to take care of handling the changes of the watched Kubernetes resource. See more on Kubernetes Informer.

Micronaut Oracle Coherence 3.0.0

The Micronaut Oracle Coherence module is now out of preview status and includes broad integration with Oracle Coherence including support for caching, messaging and Micronaut Data.

3.1.0 Breaking Changes

Retrieving the port from the Netty embedded server is no longer supported if the server is configured to bind to a random port and the server has not been started.

Micronaut Framework 3.0.0

Upgrading from Micronaut Framework 2.0 to 3.0

This section covers the steps required to upgrade a Micronaut framework 2.x application to Micronaut framework 3.0.0.

The sections below go into more detail, but at a high level the process generally involves:

  • updating versions

  • updating annotations

  • choosing a Reactive implementation

  • adjusting code affected by breaking changes

Typically, upgrading should be straightforward, but it’s possible to save yourself some work with OpenRewrite, an automated refactoring tool that you can use to make many of the required upgrade changes.

Automating Upgrades with OpenRewrite

OpenRewrite works with Micronaut applications written in Java, but OpenRewrite doesn’t currently support Kotlin or Groovy. Like any automated tool it does much of the work for you, but be sure to review the resulting changes and manually make any changes that aren’t supported by OpenRewrite, for example converting from RxJava2 to Reactor.

Note
If you will be using OpenRewrite, don’t make any upgrade changes yet that would cause your application not to compile, for example updating the Micronaut version to 3.x. This would cause application classes that use javax.inject annotations like @Singleton or RxJava2 classes like io.reactivex.Flowable to not compile since those dependencies are no longer included by default. Instead, use OpenRewrite to do the initial work and just do the steps yourself that aren’t possible or practical to automate.

Adding OpenRewrite support to your build is easy, it just requires adding the Gradle or Maven plugin and configuring the plugin to use the Micronaut upgrade recipe.

See the Gradle feature diff or the Maven feature diff to see the required build script changes.

Once you’ve made the build script changes, you can "dry-run" the Micronaut upgrade recipe to see what changes would be made.

For Gradle, run

$ ./gradlew rewriteDryRun

and view the diff report generated in build/reports/rewrite/rewrite.patch

and for Maven, run

$ ./mvnw rewrite:dryRun

and view the diff report generated in target/site/rewrite/rewrite.patch.

Then you can run the recipe for real, letting OpenRewrite update your code.

For Gradle, run

$ ./gradlew rewriteRun

and for Maven, run

$ ./mvnw rewrite:run

Once the changes have been made, you could remove the plugin, but it’s fine to leave it since OpenRewrite doesn’t run automatically, only when you run one of its commands. And there are many more recipes available beyond the Micronaut upgrade recipe that you might want to include to automate other code changes.

The plugin includes another command to list all recipes currently in the classpath (in this case the core recipes plus those added by the rewrite-micronaut module).

For Gradle, run

$ ./gradlew rewriteDiscover

and for Maven, run

$ ./mvnw rewrite:discover

and the available recipes and styles will be output to the console. Check out the OpenRewrite documentation for more information and to see the many other available recipes available.

Version Update

If you use Gradle, update the micronautVersion property in gradle.properties, e.g.

gradle.properties
micronautVersion={version}

If you use Maven, update the parent POM version and micronaut.version property in pom.xml, e.g.

pom.xml
<parent>
  <groupId>io.micronaut</groupId>
  <artifactId>micronaut-parent</artifactId>
  <version>{version}</version>
</parent>

<properties>
  ...
  <micronaut.version>{version}</micronaut.version>
  ...
</properties>

Build Plugin Update

If you use the Micronaut Gradle plugin update to the latest version.

For Maven users the plugin version is updated automatically when you update the Micronaut version.

Inject Annotations

The javax.inject annotations are no longer a transitive dependency. The Micronaut framework now ships with the Jakarta inject annotations. Either replace all javax.inject imports with jakarta.inject, or add a dependency on javax-inject to continue using the older annotations:

dependency:javax.inject:javax.inject:1[]

Any code that relied on the javax.inject annotations being present in the annotation metadata will still work as expected, however any code that interacts with them must be changed to no longer reference the annotation classes themselves. Static variables in the AnnotationUtil class (e.g. AnnotationUtil.INJECT, AnnotationUtil.SINGLETON, etc.) should be used in place of the annotation classes when working with annotation metadata.

Nullability Annotations

The Micronaut framework now only comes with its own set of annotations to declare nullability. The findbugs, javax, and jetbrains annotations are all still supported, however you must add a dependency to use them. Either switch to the Micronaut ann:core.annotation.Nullable[] / ann:core.annotation.NonNull[] annotations or add a dependency for the annotation library you wish to use.

RxJava2

The Micronaut framework no longer ships any reactive implementation as a default in any of our modules or core libraries. Upgrading to Micronaut 3 requires choosing which reactive streams implementation to use, and then adding the relevant dependency.

For those already using RxJava3 or Project Reactor, there should be no changes required to upgrade to the Micronaut framework 3. If you use RxJava2 and wish to continue using it, you must add a dependency:

dependency:io.micronaut.rxjava2:micronaut-rxjava2[gradleScope="implementation"]

In addition, if any of the Rx HTTP client interfaces were used, a dependency must be added and the imports must be updated.

dependency:io.micronaut.rxjava2:micronaut-rxjava2-http-client[gradleScope="implementation"]

Table 1. RxJava2 HTTP Client Imports
Old New

io.micronaut.http.client.RxHttpClient

io.micronaut.rxjava2.http.client.RxHttpClient

io.micronaut.http.client.RxProxyHttpClient

io.micronaut.rxjava2.http.client.proxy.RxProxyHttpClient

io.micronaut.http.client.RxStreamingHttpClient

io.micronaut.rxjava2.http.client.RxStreamingHttpClient

io.micronaut.http.client.sse.RxSseClient

io.micronaut.rxjava2.http.client.sse.RxSseClient

io.micronaut.websocket.RxWebSocketClient

io.micronaut.rxjava2.http.client.websockets.RxWebSocketClient

If the Netty based server implementation is being used, an additional dependency must be added:

dependency:io.micronaut.rxjava2:micronaut-rxjava2-http-server-netty[gradleScope="implementation"]

Note
We recommend switching to Project Reactor as that is the implementation used internally by Micronaut. Adding a dependency to RxJava2 will result in both implementations in the runtime classpath of your application.

Environment endpoint

As of 3.3.0, the environmental endpoint is now disabled by default, please see the breaking changes for how to restore functionality.

What’s new with 3.0.0

Core Features

Optimized Build-Time Metadata

Micronaut 3.0 introduces a new build time metadata format that is more efficient in terms of startup and code size.

The result is significant improvements to startup and native image sizes when building native images with GraalVM Native Image.

It is recommended that users re-compile their applications and libraries with Micronaut 3.0 to benefit from these changes.

Support for GraalVM 21.2

Micronaut has been updated to support the latest GraalVM 21.2 release.

Jakarta Inject

The jakarta.inject annotations are now the default injection annotations for Micronaut 3

Support for JSR-330 Bean Import

Using the ann:context.annotation.Import[] annotation it is now possible to import bean definitions into your application where JSR-330 (either javax.inject or jakarta.inject annotations) are used in an external library.

See the documentation on Bean Import for more information.

Support for Controlling Annotation Inheritance

api:core.annotation.AnnotationMetadata[] inheritance can now be controlled via Java’s @Inherited annotation. If an annotation is not explicitly annotated with @Inherited it will not be included in the metadata. See the Annotation Inheritance section of the documentation for more information.

Note
This is an important behavioural change from Micronaut 2.x, see the Breaking Changes section for information on how to upgrade.
Support Narrowing Injection by Generic Type Arguments

Micronaut can now resolve the correct bean to inject based on the generic type arguments specified on the injection point:

snippet::io.micronaut.docs.inject.generics.Vehicle[tags="constructor",indent=0]

For more information see the section on Qualifying by Generic Type Arguments.

Support for using Annotation Members in Qualifiers

You can now use annotation members in qualifiers and specify which members should be excluded with the new ann:context.annotation.NonBinding[] annotation.

For more information see the section on Qualifying By Annotation Members.

Support for Limiting the Injectable Types

You can now limit the exposed types of a bean using the typed member of the ann:context.annotation.Bean[] annotation:

snippet::io.micronaut.docs.inject.typed.V8Engine[tags="class",indent=0]

For more information see the section on Limiting Injectable Types.

Factories can produce bean from fields

Beans defined with the ann:context.annotation.Factory[] annotation can now produce beans from public or package protected fields, for example:

snippet::io.micronaut.docs.factories.VehicleMockSpec[tags="class",indent=0]

For more information see the Bean Factories section of the documentation.

Enhanced BeanProvider Interface

The api:context.BeanProvider[] interface has been enhanced with new methods such as iterator() and stream() as well as methods to check for bean existence and uniqueness.

New @Any Qualifier for use in Bean Factories

A new ann:context.annotation.Any[] qualifier has been introduced to allow injecting any available instance into an injection point and can be used in combination with the new BeanProvider interface mentioned above to allow more dynamic behaviour.

snippet::io.micronaut.docs.qualifiers.any.Vehicle[tags="imports,clazz", indent=0, title="Using BeanProvider with Any"]

The annotation can also be used on ann:context.annotation.Factory[] methods to allow customization of how objects are injected via the api:inject.InjectionPoint[] API.

Support for Fields in Bean Introspections

Bean introspections on public or package protected fields are now supported:

snippet::io.micronaut.docs.ioc.beans.User[tags="class", indent=0]

For more information see the "Bean Fields" section of the Bean Introspections documentation.

ApplicationEventPublisher has now a generic event type

For the performance reasons it’s advised to inject an instance of ApplicationEventPublisher with a generic type parameter - ApplicationEventPublisher<MyEvent>.

AOP Features

Support for Constructor Interception

It is now possible to intercept bean construction invocations through the api:aop.ConstructorInterceptor[] interface and ann:aop.AroundConstruct[] annotation.

See the section on Bean Life Cycle Advice for more information.

Support for @PostConstruct & @PreDestroy Interception

It is now possible to intercept @PostConstruct and @PreDestroy method invocations through the api:aop.MethodInterceptor[] interface and ann:aop.InterceptorBinding[] annotation.

See the section on Bean Life Cycle Advice for more information.

Random Configuration Values

It is now possible to set a max and a range for random numbers in configuration. For example to set an integer between 0 and 9, ${random.int(10)} can be used as the configuration value. See the documentation under "Using Random Properties" for more information.

Project Reactor used internally instead of RxJava2

Micronaut 3 uses internally Project Reactor instead RxJava 2. Project Reactor allows Micronaut 3 to simplify instrumentation, thanks to Reactor’s Context, simplifies conversion login and eases the integration with R2DBC drivers. We recommend users to migrate to Reactor. However, it is possible to continue to use RxJava. See Reactive Programming section.

Module Upgrades

Micronaut Data 3.1.0
  • Kotlin’s coroutines support. New repository interface CoroutineCrudRepository.

  • Support for AttributeConverter

  • R2DBC upgraded to Arabba-SR11

  • JPA Criteria specifications

Micronaut Micrometer 4.0.0

The Micrometer module has been upgraded and now supports repeated definitions of the @Timed annotation as well as also supporting the @Counted annotation for counters when you add the micronaut-micrometer-annotation dependency to your annotation processor classpath.

Micronaut Oracle Cloud 2.0.0

Micronaut’s Oracle Cloud Integration has been updated with support for Cloud Monitoring and Tracing.

Micronaut Cassandra 4.0.0

The Micronaut Cassandra integration now includes support for GraalVM out of the box.

Other Modules
  • Micronaut Acme 3.0.0

  • Micronaut Aws 3.0.0

  • Micronaut Azure 3.0.0

  • Micronaut Cache 3.0.0

  • Micronaut Discovery Client 3.0.0

  • Micronaut ElasticSearch 3.0.0

  • Micronaut Flyway 4.1.0

  • Micronaut GCP 4.0.0

  • Micronaut GraphQL 3.0.0

  • Micronaut Groovy 3.0.0

  • Micronaut Grpc 3.0.0

  • Micronaut Jackson XML 3.0.0

  • Micronaut Jaxrs 3.0.0

  • Micronaut JMX 3.0.0

  • Micronaut Kafka 4.0.0

  • Micronaut Kotlin 3.0.0

  • Micronaut Kubernetes 3.0.0

  • Micronaut Liquibase 4.0.2

  • Micronaut Mongo 4.0.0

  • Micronaut MQTT 2.0.0

  • Micronaut Multitenancy 4.0.0

  • Micronaut Nats Io 3.0.0

  • Micronaut Neo4j 5.0.0

  • Micronaut OpenApi 3.0.1

  • Micronaut Picocli 4.0.0

  • Micronaut Problem Json 2.0.0

  • Micronaut R2DBC 2.0.0

  • Micronaut RabbitMQ 3.0.0

  • Micronaut Reactor 2.0.0

  • Micronaut Redis 5.0.0

  • Micronaut RSS 3.0.0

  • Micronaut RxJava2 1.0.0 (new)

  • Micronaut RxJava3 2.0.0

  • Micronaut Security 3.0.0

  • Micronaut Servlet 3.0.0

  • Micronaut Spring 4.0.0

  • Micronaut SQL 4.0.0

  • Micronaut Test 3.0.0

  • Micronaut Views 3.0.0

Dependency Upgrades
  • Caffeine 2.9.1

  • Cassandra 4.11.1

  • Elasticsearch 7.12.0

  • Flyway 7.12.1

  • GraalVM 21.2.0

  • H2 Database 1.4.200

  • Hazelcast 4.2.1

  • Hibernate 5.5.3.Final

  • Hikari 4.0.3

  • Infinispan 12.1.6.Final

  • Jackson 2.12.4

  • Jaeger 1.6.0

  • Jakarta Annotation API 2.0.0

  • JAsync 1.2.2

  • JDBI 3.20.1

  • JOOQ 3.14.12

  • JUnit 5.7.2

  • Kafka 2.8.0

  • Kotlin 1.5.21

  • Kotlin Coroutines 1.5.1

  • Ktor 1.6.1

  • Liquibase 4.4.3

  • MariaDB Driver 2.7.3

  • Micrometer 1.7.1

  • MongoDB 4.3.0

  • MS SQL Driver 9.2.1.jre8

  • MySQL Driver 8.0.25

  • Neo4j Driver 4.2.7

  • Postgres Driver 42.2.23

  • Reactor 3.4.8

  • RxJava3 3.0.13

  • SLF4J 1.7.29

  • Snake YAML 1.29

  • Spock 2.0-groovy-3.0

  • Spring 5.3.9

  • Spring Boot 2.5.3

  • Testcontainers 1.15.3

  • Tomcat JDBC 10.0.8

  • Vertx SQL Drivers 4.1.1

3.0.0 Breaking Changes

Core Changes

Annotation Inheritance

Possibly the most important change in Micronaut 3.0 is how annotations are inherited from parent classes, methods and interfaces.

Micronaut 2.x did not respect the rules defined in the jdk:java.lang.reflect.AnnotatedElement[], and inherited all annotations from parent interfaces and types regardless of the presence of the jdk:java.lang.annotation.Inherited[] annotation.

With Micronaut 3.x and above only annotations that are explicitly meta-annotated with jdk:java.lang.annotation.Inherited[] are now inherited from parent classes and interfaces. This applies to types in the case where one extends another, and methods in the case where one overrides another.

Many of Micronaut’s core annotations have been annotated with @Inherited, so no change will be required, but some annotations that are either outside Micronaut or defined by user code will need changes to code or the annotation.

In general, behaviour which you wish to override is not inherited by default in Micronaut 3.x and above including Bean Scopes, Bean Qualifiers, Bean Conditions, Validation Rules and so on.

The following table summarizes the core Micronaut annotations and which are inherited and which are not:

Table 2. Annotation Inheritance in Micronaut 3.x and above
Annotation Inherited

ann:aop.Adapter[]

ann:aop.Around[]

ann:aop.AroundConstruct[]

ann:aop.InterceptorBean[]

ann:aop.InterceptorBinding[]

ann:aop.Introduction[]

ann:core.annotation.Blocking[]

ann:core.annotation.Creator[]

ann:core.annotation.EntryPoint[]

ann:core.annotation.Experimental[] (source level)

ann:core.annotation.Indexes[] & ann:core.annotation.Indexed[]

ann:core.annotation.Internal[]

ann:core.annotation.Introspected[]

ann:core.annotation.NonBlocking[]

ann:core.annotation.Nullable[]

ann:core.annotation.NonNull[]

ann:core.annotation.Order[]

ann:core.annotation.ReflectiveAccess[]

ann:core.annotation.TypeHint[]

ann:core.async.annotation.SingleResult[]

ann:core.bind.annotation.Bindable[]

ann:core.convert.format.Format[]

ann:core.convert.format.MapFormat[]

ann:core.convert.format.ReadableBytes[]

ann:core.version.annotation.Version[]

ann:context.annotation.AliasFor[]

ann:context.annotation.Any[]

ann:context.annotation.Bean[]

ann:context.annotation.BootstrapContextCompatible[]

ann:context.annotation.ConfigurationBuilder[]

ann:context.annotation.ConfigurationInject[]

ann:context.annotation.ConfigurationProperties[]

ann:context.annotation.ConfigurationReader[]

ann:context.annotation.Context[]

ann:context.annotation.DefaultImplementation[]

ann:context.annotation.DefaultScope[]

ann:context.annotation.EachBean[]

ann:context.annotation.Executable[]

ann:context.annotation.Factory[]

ann:context.annotation.NonBinding[]

ann:context.annotation.Parallel[]

ann:context.annotation.Parameter[]

ann:context.annotation.Primary[]

ann:context.annotation.Property[]

ann:context.annotation.PropertySource[]

ann:context.annotation.Prototype[]

ann:context.annotation.Replaces[]

ann:context.annotation.Requirements[]

ann:context.annotation.Requires[]

ann:context.annotation.Secondary[]

ann:context.annotation.Type[]

ann:context.annotation.Value[]

ann:http.annotation.Controller[]

ann:http.annotation.Body[]

ann:http.annotation.Consumes[]

ann:http.annotation.CookieValue[]

ann:http.annotation.CustomHttpMethod[]

ann:http.annotation.Delete[]

ann:http.annotation.Error[]

ann:http.annotation.Filter[]

ann:http.annotation.FilterMatcher[]

ann:http.annotation.Get[]

ann:http.annotation.Head[]

ann:http.annotation.Header[]

ann:http.annotation.Headers[]

ann:http.annotation.HttpMethodMapping[]

ann:http.annotation.Options[]

ann:http.annotation.Part[]

ann:http.annotation.Patch[]

ann:http.annotation.PathVariable[]

ann:http.annotation.Post[]

ann:http.annotation.Produces[]

ann:http.annotation.Put[]

ann:http.annotation.QueryValue[]

ann:http.annotation.RequestAttribute[]

ann:http.annotation.RequestAttributes[]

ann:http.annotation.RequestBean[]

ann:http.annotation.Status[]

ann:http.annotation.Trace[]

ann:http.annotation.UriMapping[]

ann:http.client.annotation.Client[]

ann:jackson.annotation.JacksonFeatures[]

ann:management.endpoint.annotation.Delete[]

ann:management.endpoint.annotation.Endpoint[]

ann:management.endpoint.annotation.Read[]

ann:management.endpoint.annotation.Sensitive[]

ann:management.endpoint.annotation.Selector[]

ann:management.endpoint.annotation.Write[]

ann:management.health.indicator.annotation.Liveness[]

ann:management.health.indicator.annotation.Readiness[]

ann:messaging.annotation.MessageBody[]

ann:messaging.annotation.MessageHeader[]

ann:messaging.annotation.MessageHeaders[]

ann:messaging.annotation.MessageListener[]

ann:messaging.annotation.MessageMapping[]

ann:messaging.annotation.MessageProducer[]

ann:messaging.annotation.SendTo[]

ann:retry.annotation.CircuitBreaker[]

ann:retry.annotation.Fallback[]

ann:retry.annotation.Recoverable[]

ann:retry.annotation.Retryable[]

ann:runtime.context.scope.Refreshable[]

ann:runtime.context.scope.ScopedProxy[]

ann:runtime.context.scope.ThreadLocal[]

ann:runtime.event.annotation.EventListener[]

ann:runtime.http.scope.RequestScope[]

ann:scheduling.annotation.Async[]

ann:scheduling.annotation.ExecuteOn[]

ann:scheduling.annotation.Scheduled[]

ann:session.annotation.SessionValue[]

@ContinueSpan

@NewSpan

@SpanTag

ann:validation.Validated[]

ann:websocket.annotation.ClientWebSocket[]

ann:websocket.annotation.OnClose[]

ann:websocket.annotation.OnError[]

ann:websocket.annotation.OnMessage[]

ann:websocket.annotation.OnOpen[]

ann:websocket.annotation.ServerWebSocket[]

ann:websocket.annotation.WebSocketComponent[]

ann:websocket.annotation.WebSocketMapping[]

When upgrading an application you may need to take action if you implement an interface or subclass a superclass and override a method.

For example the annotations defined in jakarta.validation are not inherited by default, so they must be defined again in any overridden or implemented methods.

This behaviour grants more flexibility if you need to redefine the validation rules. Note that it is still possible to inherit validation rules through meta-annotations. See the section on Annotation Inheritance for more information.

Error Response Format

The default value of jackson.always-serialize-errors-as-list is now true. That means by default the Hateoas JSON errors will always be a list. For example:

Example error response
{
  ...
  "_embedded": {
    "errors": [
      {
        "message": "Person.name: must not be blank"
      }
    ]
  }
}

To revert to the previous behavior where a singular error was populated in the message field instead of including _embedded.errors, set the configuration setting to false.

Runtime Classpath Scanning Removed

It is no longer possible to scan the classpath at runtime using the scan method of the api:context.env.Environment[] interface.

This functionality has not been needed for some time as scanning is implemented at build time through Bean Introspections.

Inject Annotations

Micronaut now provides the jakarta.inject annotations as a transitive dependency instead of the javax.inject annotations. To continue using the old annotations, add the following dependency.

dependency:javax.inject:javax.inject:1[]

Nullable Annotations

Micronaut no longer exports any third party dependency for nullability annotations. Micronaut now provides its own annotations for this purpose (api:core.annotation.Nullable[] and api:core.annotation.NonNull[]) that are used for our APIs. To continue using other nullability annotations, simply add the relevant dependency.

Internally, Micronaut makes use of a third party annotation that may manifest as a warning in your project:

warning: unknown enum constant When.MAYBE
  reason: class file for javax.annotation.meta.When not found

This warning is harmless and can be ignored. To eliminate this warning, add the following dependency to your project’s compile only classpath:

dependency:com.google.code.findbugs:jsr305[gradleScope="compileOnly"]

Server Filter Behavior

In Micronaut 2 server filters could have been called multiple times in the case of an exception being thrown, or sometimes not at all if the error resulted before route execution. This also allowed for filters to handle exceptions thrown from routes. Filters have changed in Micronaut 3 to always be called exactly once for each request, under all conditions. Exceptions are no longer propagated to filters and instead the resulting error response is passed through the reactive stream.

In the case of a response being created as a result of an exception, the original cause is now stored as a response attribute (api:http.HttpAttributes#EXCEPTION[]). That attribute can be read by filters to have context for the error HTTP response.

The api:http.filter.OncePerRequestHttpServerFilter[] class is now deprecated and will be removed in the next major release. The api:http.filter.OncePerRequestHttpServerFilter[] stores a request attribute when the filter is executed and some functionality may rely on that attribute existing. The class will still create the attribute but it is recommended to instead create a custom attribute in your filter class and use that instead of the one created by api:http.filter.OncePerRequestHttpServerFilter[].

There is also a minor behavior change in when the response gets written. Any modifications to the response after the underlying onNext call is made will not have any effect as the response has already been written.

HTTP Compile Time Validation

Compile time validation of HTTP related classes has been moved to its own module. To continue validating controllers, websocket server classes add http-validation to the annotation processor classpath.

dependency:io.micronaut:micronaut-http-validation[gradleScope="annotationProcessor"]

Decapitalization Strategy

For many cases, one common one being introspections, getter names like getXForwarded() would result in the bean property being XForwarded. The name will now be xForwarded. This can affect many areas of the framework where names like XForwarded are used.

@Order default

Previously the default order value for the @Order annotation was the lowest precedence. It is now 0.

Classes Renaming
  • RxJavaRouteDataCollector has been renamed to DefaultRouteDataCollector.

  • RxJavaBeanDefinitionDataCollector.html has been renamed to DefaultBeanDefinitionDataCollector.

  • RxJavaHealthAggregator has been renamed to DefaultHealthAggregator

Deprecation Removal

Classes, constructors, etc. that have been deprecated in previous versions of Micronaut have been removed.

Reflective Bean Map

In several places in Micronaut, it is required to get a map representation of your object. In previous versions, a reflection based strategy was used to retrieve that information if the class was not annotated with @Introspected. That functionality has been removed and it is now required to annotate classes with @Introspected that are being used in this way. Any class may be affected if it is passed as an argument or returned from any controller or client, among other use cases.

Previously the secure configuration for cookies was only respected if the request was determined to be sent over https. Due to a number of factors including proxies, HTTPS requests can be presented to the server as if they are HTTP. In those cases the setting was not having any effect. The setting is now respected regardless of the status of the request. If the setting is not set, cookies will be secure if the request is determined to be HTTPS.

Server Error Route Priority

Previously if a route could not be satisfied, or an HttpStatusException was thrown, routes for the relevant HTTP status was searched before routes that handled the specific exception. In Micronaut 3 routes that handle the exception will be searched first, then routes that handle the HTTP status.

Status Route Default Response Status

Status error routes will now default to produce responses with the same HTTP status as specified in the @Error annotation. In previous versions a 200 OK response was created. For example:

@Error(status = HttpStatus.UNSUPPORTED_MEDIA_TYPE)
String unsupportedMediaTypeHandler() {
    return "not supported";
}

The above method will result in a response of HTTP status 415 with a body of "not supported". Previously it would have been a response of HTTP status 200 with a body of "not supported". To specify the desired response status, either annotate the method with @Status or return an HttpResponse.

No Longer Possible to Inject a List of Provider

In Micronaut 2.x it was possible to inject a List<javax.inject.Provider>, although this was undocumented behaviour. In Micronaut 3.x injecting a list of Provider instances is no longer possible and you should instead use the api:context.BeanProvider[] API which provides stream() and iterator() methods to provide the same functionality.

Injecting ExecutorService

In previous versions of Micronaut it was possible to inject an ExecutorService without any qualifiers and the default Netty event loop group would be injected. Because the event loop should not be used for general purpose use cases, the injection will now fail by default with a non unique bean exception. The injection point should be qualified for which executor service is desired.

Subclasses Returned From Factories Not Injectable

It is no longer possible to inject the internal implementation type from beans produced via factories. The type returned from the factory or any of its super types are able to be injected.

For example:

import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton;

public class ExecutorFactory {
    @Singleton
    public ExecutorService executorService() {
        return ForkJoinPool.commonPool();
    }
}

In the above case, if the ExecutorService had been already been retrieved from the context in previous logic, a call to context.getBean(ForkJoinPool.class) would locate the already created bean. This behaviour was inconsistent because if the bean had not yet been created then this lookup would not work. In Micronaut 3 for consistency this is no longer possible.

You can however restore the behaviour by changing the factory to return the implementation type:

import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton;
public class ExecutorFactory {

    @Singleton
    public ForkJoinPool executorService() {
        return ForkJoinPool.commonPool();
    }
}
No Longer Possible to Define AOP Advice on a Bean Produced from a Factory with Constructor arguments

In previous versions of Micronaut it was possible to define AOP advice to a factory method that returned a class that featured constructor arguments. This could lead to undefined behaviour since the argument of the generated proxy which would be dependency injected by the framework may be different from manually constructed proxy target.

The following definition is now invalid in Micronaut 3 and above and will lead to a compilation error:

import io.micronaut.context.annotation.*;
import io.micronaut.runtime.context.scope.*;

@Factory
class ExampleFactory {

    @ThreadLocal
    Test test() {
        return new Test("foo");
    }
}

class Test {
    // illegally defines constructor arguments
    Test(String name) {}
}
Implementations of javax.inject.Provider No Longer Generate Factories

In Micronaut 2.x if you defined a bean that implemented the javax.inject.Provider interface then the return type of the get method also automatically became a bean.

For example:

import javax.inject.Provider;
import javax.inject.Singleton;

@Singleton
public class AProvider implements Provider<A> {
    @Override
    public A get() {
        return new AImpl();
    }
}

In the above example a bean of type A would automatically be exposed by Micronaut. This behaviour is no longer supported and instead the ann:context.annotation.Factory[] annotation should be used to express the same behaviour. For example:

import io.micronaut.context.annotation.Factory;
import javax.inject.Provider;
import javax.inject.Singleton;

@Factory
public class AProvider implements Provider<A> {
    @Override
    @Singleton
    public A get() {
        return new AImpl();
    }
}
Fewer Executable Methods Generated for Controllers and Message Listeners

Previous versions of Micronaut specified the ann:context.annotation.Executable[] annotation as a meta-annotation on the ann:http.annotation.Controller[], ann:http.annotation.Filter[] and ann:messaging.annotation.MessageListener[] annotations. This resulted in generating executable method all non-private methods of classes annotated with these annotations.

In Micronaut 3.x and above the ann:context.annotation.Executable[] has been moved to a meta-annotation of ann:http.annotation.HttpMethodMapping[] and ann:messaging.annotation.MessageMapping[] instead to reduce memory consumption and improve efficiency.

If you were relying on the presence of these executable methods you must explicitly annotate methods in your classes with ann:context.annotation.Executable[] to restore this behaviour.

GraalVM changes

In previous versions of Micronaut annotating a class with @Introspected automatically added it to the GraalVM reflect-config.json file. The original intended usage of the annotation is to generate Bean Introspection Metadata so Micronaut can instantiate the class and call getters and setters without using reflection.

Starting in Micronaut 3.x the @Introspected annotation doesn’t add the class to the GraalVM reflect-config.json file anymore, because in most of the cases is not really necessary. If you need to declare a class to be accessed by reflection, use the @ReflectiveAccess annotation instead.

Another change is regarding the GraalVM resources created at compile-time. In previous versions of Micronaut adding a dependency on io.micronaut:micronaut-graal triggered the generation of the GraalVM resource-config.json that included all the resources in src/main/resources so they were included in the native image. Starting in Micronaut 3.x that is done in either the Gradle or Maven plugins.

Exception Handler Moves

Two exception handlers that were in micronaut-server-netty have now been moved to micronaut-server since they were not specific to Netty. Their package has also changed as a result.

Table 3. Package changes
Old New

http-server-netty/src/main/java/io/micronaut/http/server/netty/converters/DuplicateRouteHandler.java

http-server/src/main/java/io/micronaut/http/server/exceptions/DuplicateRouteHandler.java

http-server-netty/src/main/java/io/micronaut/http/server/netty/converters/UnsatisfiedRouteHandler.java

http-server/src/main/java/io/micronaut/http/server/exceptions/UnsatisfiedRouteHandler.java

Module Changes

New package for Micronaut Cassandra

The classes in Micronaut Cassandra have been moved from io.micronaut.configuration.cassandra to io.micronaut.cassandra package.

Micronaut Security

Many of the APIs in the Micronaut Security module have undergone changes. Please see the Micronaut Security documentation for the details.

Groovy changes

In previous version the missing property wouldn’t set the field value to null as it would do for the Java code, in the version 3 it should behave in the same way.

Please refactor to use the default value in the @Value annotation:

@Nullable
@Value('${greeting}')
protected String before = "Default greeting"

@Nullable
@Value('${greeting:Default greeting}')
protected String after

Micronaut Framework 2.5.0

What’s new with 2.5.0

Core Features

IO Stream Support

It is now possible to define a body argument of a controller method with an InputStream. For example @Body InputStream inputStream. Note that you must offload the execution to another thread pool to avoid blocking the event loop when reading the stream. InputStream can also be returned from controller methods.

HTTP to HTTPS redirect with Dual Protocol

If Dual Protocol is enabled, now it is possible to redirect all HTTP requests automatically to the HTTPS port. See more information about how to enable and configure it.

GraalVM 21.1.0 Support

Micronaut has been updated to support the latest GraalVM 21.1.0 release with the Gradle and Maven plugins now defaulting to 21.1.0.

Support for JDK 16 and Gradle 7.0 in Micronaut Launch

Micronaut Launch has been updated with support for JDK 16 and Gradle 7.0.

Random Configuration Values

It is now possible to set a max and a range for random numbers in configuration. For example to set an integer between 0 and 9, ${random.int(10)} can be used as the configuration value. See the documentation under "Using Random Properties" for more information.

Module Upgrades

Micronaut Data 2.4.0

Huge Micronaut Data update including many new features including:

  • Full support for immutable entities. You can use Java 16 records or Kotlin immutable data classes

  • Integrated support for R2DBC, now the data-r2dbc module is a part of the data project and shares the same code with JDBC

  • Optimistic locking for JDBC/R2DBC

  • Repositories now support batch insert/update/delete even with a custom query

  • Rewritten entity mapper allows more complex mapping for JDBC/R2DBC entities

  • Support for @JoinTable and @JoinColumn annotations

  • A lot of bugfixes!

Micronaut Micrometer 3.4.0

The Micrometer module has been upgraded and now supports repeated definitions of the @Timed annotation as well as also supporting the @Counted annotation for counters when you add the micronaut-micrometer-annotation dependency to your annotation processor classpath.

Micronaut Oracle Cloud 1.3.0

Micronaut’s Oracle Cloud Integration has been updated with support for Cloud Monitoring and Tracing.

Other Modules
  • Micronaut Security 2.4.2

  • Micronaut Azure 2.2.0

  • Micronaut Aws 2.6.0

  • Micronaut Grpc 2.4.0

  • Micronaut OpenApi 2.4.0

  • Micronaut Kafka 3.3.0

  • Micronaut Flyway 3.6.0

  • Micronaut Liquibase 3.3.1

  • Micronaut Discovery Client 2.4.0

  • Micronaut ElasticSearch 2.3.0

Dependency Upgrades

  • Kafka 2.8.0

  • GraalVM 21.1.0

  • Liquibase 4.3.4

  • Flyway 7.7.3

  • Elasticsearch 7.12.0

2.5.0 Breaking Changes

In previous versions of Micronaut it was possible to read the body of a request in a server filter under some conditions. Reading the request body in a filter has historically been inconsistent because the body is not read in many cases. In Micronaut 2.4, the body was read until the route arguments were satisfied, and then the server filters were executed. This lead to issues with memory leaks in some cases and is inefficient because a filter may skip route execution altogether by not proceeding the chain, thus the body did not need to be read. In Micronaut 2.5 the body will not be read until after filters are executed. This may lead to cases where the body was available in a filter and is no longer available.

Micronaut Framework 2.4.0

What’s new with 2.4.0

Core Features

Jakarta Inject

The jakarta.inject inject annotations are now supported as an alternative to javax.inject. Micronaut 3 will change the default inject annotations to Jakarta, however the javax annotations will continue to be supported if added to your build explicitly.

Micronaut 3 will change the bean context API to return our custom provider contract, api:context.BeanProvider[]. We suggest existing applications to change to use that interface instead of javax.inject.Provider, however both the jakarta.inject.Provider and javax.inject.Provider interfaces will continue to be supported.

Core Nullability Annotations

With the future of JSR-305 unclear and issues with regards to the module system with existing solutions, Micronaut 2.4 will replace usages of Spotbugs with core nullability annotations: ann:core.annotation.Nullable[] and ann:core.annotation.NotNull[].

Existing applications should switch to using these annotations. If other annotations are preferable, the dependency should be added explicitly to your build because no third party Nullable or NonNull annotations will be available transitively in the next major version.

Improvements to Interceptor Binding

Micronaut’s support for AOP interceptors has been improved allowing interceptors to be attached to any annotation through the use of api:inject.annotation.AnnotationMapper[] instances. It is also now possible to bind multiple api:aop.MethodInterceptor[] instances to a single annotation instead of there being a 1-to-1 mapping between annotation and interceptor.

From 2.4.x onwards the recommending way to define AOP advise is to use the ann:aop.InterceptorBinding[] annotation on the annotation you wish to trigger AOP advise:

snippet::io.micronaut.docs.aop.around.NotNull[tags="imports,annotation", indent=0, title="Around Advice Annotation Example"]

Then use ann:aop.InterceptorBean[] on the api:aop.MethodInterceptor[] you wish to bind to the above advise:

snippet::io.micronaut.docs.aop.around.NotNullInterceptor[tags="imports,interceptor", indent=0, title="MethodInterceptor Example"]

Multiple api:aop.MethodInterceptor[] types can bind to a single advise annotation and any given interceptor can bind to multiple annotations.

JSON Error Responses

In previous versions of Micronaut, to control the format of error response bodies, it required replacing all of the existing api:http.server.exceptions.ExceptionHandler[] instances. In Micronaut 2.4, the logic to create error response bodies has been moved to a single bean that implements api:http.server.exceptions.response.ErrorResponseProcessor[]. Now instead of having to replace many beans to have a consistent format, only a single bean needs to be replaced. The default implementation behaves the same as in previous versions to maintain backward compatibility.

Micronaut Data

Support for Java 14+ Records with JDBC
package example;

import edu.umd.cs.findbugs.annotations.Nullable;
import io.micronaut.data.annotation.*;
import java.util.Date;

@MappedEntity
record Book(
        @Id @GeneratedValue @Nullable Long id,
        @DateCreated @Nullable Date dateCreated,
        String title,
        int pages) {
    Book(String title, int pages) {
        this(null, null, title, pages)
    }
}
Persistence Events Support

Micronaut Data JPA, JDBC and R2DBC now support persistence events on either entities or Micronaut beans. For example:

package example;

import io.micronaut.data.annotation.event.PrePersist;
import javax.inject.Singleton;

@Singleton
public class AccountUsernameValidator {
    @PrePersist
    void validateUsername(Account account) {
        final String username = account.getUsername();
        if (username == null || !username.matches("[a-z0-9]+")) {
            throw new IllegalArgumentException("Invalid username");
        }
    }
}

Integration with Oracle Coherence CE

We are pleased to announce a first milestone release of Micronaut integration with Oracle Coherence Community Edition, which makes implementation of Micronaut applications with a Coherence back end a breeze.

Below are some of the features supported by the various modules within micronaut-coherence project:

Micronaut Data Support

The micronaut-coherence-data module alows you to use Micronaut Data with Coherence as a back end data store.

Dependency Injection of Coherence-managed Objects

A new micronaut-coherence module provides factories for commonly used Coherence objects, such as Cluster, Session, NamedMap, NamedCache, NamedTopic, and many others, which allows you to easily inject those objects into your application classes.

Listeners for Coherence Events

The micronaut-coherence module also provides support for Coherence server- and client-side events via Micronaut event listeners.

Micronaut Messaging Support

Finally, the micronaut-coherence module provides support for Micronaut Messaging using Coherence Topics.

Micronaut Caching Support

The micronaut-coherence-cache module adds support for using Coherence as a back end for Micronaut Cache.

Micronaut Distributed Config Support

The micronaut-coherence-distributed-configuration module adds support for using Coherence as a store for Micronaut Distributed Configuration.

Micronaut HTTP Sessions Support

The micronaut-coherence-session module adds support for using Coherence as a store for Micronaut HTTP Sessions.

Cloud Features

Easier Configuration of Oracle Cloud Autonomous Database

A new micronaut-oraclecloud-atp has been added that makes it easier to automatically download the Oracle Wallet definition and connect to Autonomous Database on Oracle Cloud.

Support for Oracle Cloud Monitoring via Micrometer

A new micronaut-oraclecloud-micrometer module has been added that adds support for exporting Micrometer metrics to Oracle Cloud.

Official Kubernetes Client

With the new micronaut-kubernetes-client module you can now inject apis objects from the official Kubernetes Java SDK as regular beans.

In Micronaut 3 this new module will be used as primary kubernetes client, making the current one deprecated.

Micronaut AWS

Micronaut AWS now includes the new AWS SDK v2 that has support for GraalVM out of the box. Every service included in the module like S3, Parameter Store, SES, SQS,…​ is now compatible with Micronaut-GraalVM integration.

Module Upgrades

  • Micronaut Oracle Cloud 1.1.11.2.1

  • Micronaut Data 2.2.42.3.0

  • Micronaut R2DBC 1.0.11.1.0

  • Micronaut Kubernetes 2.2.02.3.0

  • Micronaut AWS 2.3.02.4.0

Dependency Upgrades

  • Jaeger Version 1.3.11.5.0

  • Zipkin Version 2.15.02.16.3

2.4.0 Breaking Changes

Methods annotated with @CircuitBreaker that used the includes or excludes members were not functioning correctly. The circuit breaker was opening for exceptions that did not match the supplied exception types. This has been changed to correctly respect the includes and excludes.

Micronaut Framework 2.3.0

What’s new with 2.3.0

Core Features

Banner

A new customizable banner is now displayed when the application starts up. See Micronaut Banner for more information.

Compatibility with GraalVM 21.0.0

This release is compatible with the latest GraalVM 21.0.0 release, updating and testing all modules against the latest version of native image.

Improved Support for Records

Java 14+ Records can now be used to define Configuration Properties. By default when @ConfigurationProperties is used on a record, configuration injection is applied. For example:

package example;
import io.micronaut.context.annotation.*;
import javax.validation.constraints.*;

@ConfigurationProperties("example")
record Example(@Min(20) int num, String name) {
}
Bean Introspections Now Support Execution Handles

A api:core.beans.BeanIntrospection[] can now declare methods that should generate reflection-free execution handles. This feature allows calling other methods (besides setters) on introspections without using reflection.

Improved Support for Copy Constructors and Immutable Types

An immutable api:core.beans.BeanIntrospection[] (like Java Records as mentioned above) requires different handling when you need to create a new instance with a particular property modified. A typical pattern for this is to construct a new instance passing all existing values plus the modified value (see for example Lombok’s @With).

Micronaut’s Bean Introspections now support this pattern. For example:

val introspection = BeanIntrospection.getIntrospection(Example.java);
Example example = introspection.instantiate(10, "Test");
assertEquals(10, example.num());
example = introspection.getRequiredProperty("num", int.class)
             .withValue(example, 20);
assertEquals(20, example.num());

The new withValue method automatically creates a new instance, populating the existing properties and returning the instance.

Micronaut computes at compile time an efficient copy-constructor approach that only returns a new instance if the value changes.

HTTP Features

Locale Resolution

A new interface api:http.server.util.HttpLocaleResolver[] has been introduced to support resolving a locale from a given request in multiple ways. A java.util.Locale object can now be a parameter to controller and client methods to automatically bind the locale to/from the request. See the documentation for more information.

Host Resolution

It is now possible to validate a resolved host against a list of regular expressions patterns. See the documentation for more information.

Cloud Features

New CI/CD Deployment Workflows for Github Actions in Launch

Micronaut Launch has been updated to include CI/CD workflows to deploy to common container-based Cloud environments including Oracle Cloud Function, Azure Container Instance and Google Cloud Run.

Combined with the ability to Push to Github this makes it a breeze to set up Micronaut applications to be deployed to the Cloud.

Google Cloud Secret Manager

Micronaut JMS

A new Micronaut JMS module (currently in preview) to support JMS messaging including ActiveMQ and Amazon SQS has been added with full support for GraalVM native image. See the Micronaut JMS documentation for more information.

Other improvements

While Micronaut has always followed the Semantic Versioning principles, our non-stable versioning didn’t match the specification. For example, our snapshots were versioned as 1.2.3.BUILD-SNAPSHOT as opposed to 1.2.3-SNAPSHOT.

Since Micronaut 2.3, all our artifacts' non-stable versions will be like:

  • Snapshots: 1.2.3-SNAPSHOT.

  • Milestones: 1.2.3-M1, 1.2.3-M2, etc.

  • Release candidates: 1.2.3-RC1, 1.2.3-RC2, etc.

Module Upgrades

  • Micronaut XML 2.1.02.2.1

  • Micronaut Cache 2.2.02.3.0

  • Micronaut Security 2.2.22.3.0

  • Micronaut Spring 2.1.23.2.0

  • Micronaut GCP 3.3.03.4.0

  • Micronaut AWS 2.2.52.3.0

  • Micronaut OpenAPI 2.2.22.3.0

  • Micronaut SQL 3.3.53.4.0

  • Micronaut Views 2.1.02.2.1

  • Micronaut Test 2.2.12.3.2

  • Micronaut PicoCLI 3.1.03.2.0

  • Micronaut RabbitMQ 2.2.22.3.2

  • Micronaut Flyway 3.1.03.3.0

  • Micronaut Kubernetes 2.1.02.2.0

  • Micronaut Multitenancy 2.2.33.0.0 (Group ID changed to io.micronaut.multitenancy)

  • Micronaut JMS (new) 1.0.0.M1

Dependency Upgrades

  • PicoCLI 4.5.24.6.1

  • Caffeine 2.8.62.8.8

  • Netty 4.1.56.Final4.1.58.Final

  • Spring 5.2.9.RELEASE5.3.1

  • Spring Boot 2.3.4.RELEASE2.4.0

  • GraalVM 20.3.021.0.0

  • Tomcat JDBC 9.0.409.0.41

  • Flyway 7.0.47.4.0

2.3.0 Breaking Changes

The micronaut.server.multipart.enabled setting previously was not respected for the Netty server implementation. The setting is now honored and if explicitly set to false, all multipart requests will be rejected.

Micronaut Framework 2.2.0

What’s new with 2.2.0

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:

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

Or via the Micronaut Launch API:

$ curl https://launch.micronaut.io/demo.zip?build=gradle_kotlin -o demo.zip && unzip demo.zip -d demo && cd demo
$ ./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

2.2.0 Breaking Changes

Kotlin suspend functions in controllers that return null now correctly respond with a 404. This behavior was inconsistent with other return types in previous versions and returned a 200 OK response.

Micronaut Framework 2.1.0

What’s new with 2.1.0

Core Features

Introspections for JDK 14 Records

It is now possible to define bean introspections on JDK 14+ record types (note these currently require the ––enable–preview flag to the compiler and JVM).

@Client + Kotlin

@Client interfaces now support suspend methods!

Default Environment

Micronaut 2.1 introduces the concept of a default environment. One or more default environments can be set and they will apply if no other environments are explicitly specified or deduced. See the environments documentation for information on how to use this new feature.

@Order Annotation

The ann:core.annotation.Order[] annotation has been added to support supplying bean order for factory methods or for those who prefer the use of annotations over the api:core.order.Ordered[] interface.

Kotlin 1.4

Micronaut now ships with Kotlin 1.4 for those users using Kotlin.

Build Features

New Gradle Plugin

A new Gradle plugin is available that provides a more expressive way to define a Micronaut application and includes awesome new features for GraalVM Native Image and Docker. The minimum required build to build a Micronaut application is now:

Micronaut Minimal Gradle Build
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

Building a Native Image is then as simple as:

$ ./gradlew nativeImage

Whilst building a docker image using GraalVM Native Image can be done with:

$ ./gradlew dockerBuildNative

# Or to push a native image to a Docker registry
$ ./gradlew dockerPushNative

Web Features

Client Binding API

A new API has been created to allow for binding declarative HTTP client method arguments to an HTTP request. See the documentation for more information.

Websocket Improvements

Query parameters are now respected and bindable in the Micronaut websocket support.

HttpResponse Improvements

Cookies in HTTP responses from the client side are now retrievable on the HttpResponse. These are the cookies found in the Set-Cookie header.

Cloud Features

Support for Oracle Cloud SDK

A new GraalVM Native Image compatible module for Oracle Cloud SDK has been added allowing you to use any part of the Oracle Cloud SDK with Native Image and also enhancing the SDK with RxJava 2 support.

Support for Oracle Function

Support has been added for building Oracle Functions deployable to Oracle Cloud including the ability to compute the functions in native images using GraalVM.

Support for Google Pub/Sub

Thanks to Vinicius Carvalho at Google, Micronaut now features dedicated support for Google Pub/Sub for seamless messaging in Google Cloud.

Support for Google Cloud Log Format

Thanks to Vinicius Carvalho at Google, Micronaut can now output logs in the official JSON format supported by Stackdriver on Google Cloud

Liveness/Readiness Probes

Micronaut’s /health endpoint now allows you to distinguish liveness and readiness probes at the URIs /health/liveness and /health/readiness. Micronaut Launch’s Kubernetes support has been updated to generate a Kubenetes descriptor that is configured to with these probe endpoints by default.

Module Upgrades

  • Micronaut AWS 2.1.0

  • Micronaut Acme 2.0.0

  • Micronaut Azure 2.0.1

  • Micronaut Cache 2.1.0

  • Micronaut Cassandra 3.0.0

  • Micronaut Data 2.0.0

  • Micronaut Elasticsearch 2.0.1

  • Micronaut Flyway 2.1.1

  • Micronaut GCP 3.2.1

  • Micronaut GraphQL 2.1.0

  • Micronaut Groovy 2.1.0

  • Micronaut gRPC 2.0.5

  • Micronaut Ignite 1.0.0.RC1

  • Micronaut Kafka 3.0.0

  • Micronaut Kotlin 2.1.1

  • Micronaut Liquibase 2.1.0

  • Micronaut Micrometer 3.0.1

  • Micronaut Mongo DB 3.0.0

  • Micronaut Neo4j 4.0.0

  • Micronaut Open API 2.1.0

  • Micronaut Oracle Cloud 1.0.0

  • Micronaut Picocli 3.0.0

  • Micronaut RabbitMQ 2.1.0

  • Micronaut Redis 3.0.0

  • Micronaut Security 2.1.0

  • Micronaut Servlet 2.0.0

  • Micronaut Sql 3.1.0

  • Micronaut Test 2.1.0

  • Micronaut Xml 2.0.0

Dependency Upgrades

  • Commons Dbcp 2.8.0

  • Dekorate 1.0.3

  • Elasticsearch 7.8.1

  • Flyway 6.5.4

  • gRPC 1.32.1

  • Hibernate 5.4.21.Final

  • Ignite 2.8.1

  • JUnit 5.7.0

  • Kotlin 1.4.10

  • Ktor 1.4.0

  • Liquibase 3.10.2

  • MSSQL Driver 8.4.1.jre8

  • MariaDB Driver 2.6.2

  • Micrometer 1.5.5

  • Mongo Driver 4.1.0

  • Mongo Reactive Driver 4.1.0

  • Neo4j Driver 4.1.1

  • Netty 4.1.52.Final

  • Picocli 4.5.1

  • Postgres Driver 42.2.16

  • Redis Lettuce 5.3.4.RELEASE

  • Tomcat Jdbc 9.0.38

Micronaut Framework 2.0.0

What’s new with 2.0.0

Core Features

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
import io.micronaut.core.annotation.Creator;

@io.micronaut.core.annotation.Introspected
interface Example {
    String getName();

    @Creator
    static Example create(String name) {
        return () -> name;
    }
}
Support for Analyzing the Injection Point

Micronaut’s Dependency Injection implementation has been improved such that you can now receive an api:inject.InjectionPoint[] instance to any ann:context.annotation.Factory[] 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:

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

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

@Bean
protected DefaultHttpClient httpClient(InjectionPoint<?> injectionPoint) {
    String url = metadata.stringValue(Client.class).orElse(null);
    if (url != null) {
        ......
        URL parsedUrl = new URL(url) //handle exception
        return new DefaultHttpClient(parsedUrl);
    } else {
        return new DefaultHttpClient();
    }
}
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 api:context.ApplicationContextBuilder[] interface:

Enabling Eager Initialization
public class Application {

    public static void main(String[] args) {
        Micronaut.build(args)
            .eagerInitSingletons(true) // (1)
            .mainClass(Application.class)
            .start();
    }
}
  1. Setting eager init to true initializes all singletons

It is also possible to just eager init configuration using eagerInitConfiguration which will initialize all ann:context.annotation.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 available on Linux, MacOS X and Windows.

Micronaut Launch

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

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

Or by visiting https://launch.micronaut.io in your browser.

Run curl 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
$ mn feature-diff --features=azure-function
--- micronaut-cli.yml
+++ micronaut-cli.yml
@@ -3,4 +3,4 @@
 testFramework: junit
 sourceLanguage: java
 buildTool: gradle
-features: [app-name, application, gradle, http-client, java, junit, logback, netty-server, shade, yaml]
+features: [app-name, application, azure-function, azure-function-http, gradle, java, junit, logback, yaml]


--- host.json
+++ host.json
@@ -1,0 +1,7 @@
+{
+  "version": "2.0",
+  "extensionBundle": {
+    "id": "Microsoft.Azure.Functions.ExtensionBundle",
+    "version": "[1.*, 2.0.0)"
+  }
+}

GraalVM Improvements

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 Image 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

  • Postgres

  • MS SQL

  • H2

  • MySQL

Support for Flyway Migrations in Native Image

The Micronaut Flyway module has been updated with GraalVM Native Image support 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 includes support for Native Image 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

The Micronaut jOOQ module includes support for Native Image and it’s possible to use it with SimpleFlatMapper.

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
<parent>
    <groupId>io.micronaut</groupId>
    <artifactId>micronaut-parent</artifactId>
    <version>${micronaut.version}</version>
</parent>
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:

$ ./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.

HTTP Features

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 ann:scheduling.annotation.ExecuteOn[] 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 ann:http.annotation.RequestBean[] 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:

$ mn create-app myapp --features jetty-server    # for Jetty
$ mn create-app myapp --features tomcat-server   # for Tomcat
$ 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.

Note
This also applies to @Error routes making it possible to send different error responses for different content types
Tip
To add XML support use the Jackson XML module
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 api:http.client.RxHttpClient[] instance. You can now inject the default client simply with:

@Inject RxHttpClient client;

If no host is provided at the time of a request, a api:http.client.exceptions.NoHostException[] 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 ProxyHttpClient for more information.

Endpoint Sensitivity

It is now possible to control the sensitivity of individual endpoint methods. The ann:io.micronaut.management.endpoint.annotation.Sensitive[] 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 Denis Stepanov and Lajos Gathy for their contributions in this area.

Kotlin Improvements

Support for KTOR in Micronaut Launch

You can generate a Micronaut + Ktor 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.

Serverless Improvements

Support for Google Cloud Function

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

Support for Microsoft Azure Function

You can now write Serverless functions that target Microsoft Azure using Micronaut. See the Micronaut Azure 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.).

See the documentation for the Cache module for more information.

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 Dan Maas for this contribution).

In addition, support has been added for Oracle Universal Connection Pool. Thanks to Todd Sharp 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 Security module for more information.

New Reactive Modules

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

For RxJava 3:

dependency:io.micronaut.rxjava3:micronaut-rxjava3[]

For Reactor:

dependency:io.micronaut.reactor:micronaut-reactor[]

And legacy support for RxJava 1:

dependency:io.micronaut.rxjava1:micronaut-rxjava1[]

Included within the new RxJava 3 and Reactor modules are variants of api:http.client.RxHttpClient[] called Rx3HttpClient and ReactorHttpClient respectively.

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

dependency:io.micronaut.rxjava3:micronaut-rxjava3-http-client[]

To use the Reactor HTTP client add:

dependency:io.micronaut.rxjava3:micronaut-reactor-http-client[]

New Micronaut NATS module

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

See the documentation for Micronaut Nats for more information.

Thanks to Joachim Grimm 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

  • Jackson 2.10.32.11.0

Micronaut Framework 1.3.0

1.3.0 Breaking Changes

The following changes could potentially be considered to be breaking changes, however the likelihood of any negative impact is low.

  • The order of the configuration files provided by MICRONAUT_CONFIG_FILES or micronaut.config.files was overriding system properties and environment variables. The files are now ordered between the environment and configuration files which means they will no longer override environment variables or system properties. In addition which file within the list had priority was non deterministic. Later files now have precedence over earlier files in the list.

  • Routes that are binding to a body type that is a String, byte[], or ByteBuffer will no longer be decoded and the raw body will be bound directly to the argument. Because decoding is no longer happening, if a body is sent that is considered invalid according to the content type of the request, it will be bound to the body argument anyway. This is different than previous behavior where an exception would be thrown if the body was invalid.

  • Concrete types are now preferred when creating a class hierarchy. The most common case where this will have an impact is converters. Converters that match super classes of the target type will be preferred over converters that match an interface that the target type implements.

What’s new with 1.3.0

Support for GraalVM 20.0.0

Micronaut supports creating native-images using GraalVM 20.0.0 for both JDK 8 and JDK 11.

Startup and Memory Usage Optimizations

Startup performance and memory usage (20%) have been improved.

Micronaut Data Integration

Micronaut Data has been added to the micronaut-bom and you can now use the CLI to create Micronaut Data projects:

Setting up Micronaut Data JPA
# add --build maven for maven
$ mn create-app myapp --features data-hibernate-jpa
Setting up Micronaut Data JDBC
# add --build maven for maven
$ mn create-app myapp --features data-jdbc

Initial Support for Kotlin Coroutines and Flow

Initial support for Kotlin Coroutines and the Flow type has been added when used as the return type of controller methods.

Thanks to Konrad Kamiński for this contribution.

Immutable @ConfigurationProperties and @EachProperty

Support for immutable ann:context.annotation.ConfigurationProperties[] has been added by annotating the constructor of any configuration class with ann:context.annotation.ConfigurationInject[]. See the documentation on Immutable Configuration for more information.

snippet::io.micronaut.docs.config.itfce.EngineConfig[tags="imports,class",indent=0,title="@ConfigurationProperties Example"]

  1. The ann:context.annotation.ConfigurationProperties[] annotation takes the configuration prefix and is declared on an interface

  2. You can use ann:core.bind.annotation.Bindable[] to set a default value if you want

  3. Validation annotations can be used too

  4. You can also specify references to other ann:context.annotation.ConfigurationProperties[] beans.

  5. You can nest immutable configuration

  6. Optional configuration can be indicated by returning an Optional or specifying @Nullable

Ability to Configure Log Levels via Properties

Log levels can now be configured via properties defined in application.yml (and environment variables) with the log.level prefix:

logger:
    levels:
        foo.bar: ERROR

New Micronaut Cache Modules

Micronaut Cache has been updated to support Hazelcast and Ehcache as additional Cache providers.

New Micronaut Jackson XML Module

Support for parsing and serializing to XML has been added with a new Jackson XML module.

dependency:micronaut-jackson-xml[groupId="io.micronaut.xml"]

Thanks to Sergey for this contribution.

Micronaut OpenAPI (Swagger) 1.3 Update

Micronaut OpenAPI has been updated with loads of improvements including the ability to automatically generate UIs for Swagger output as part of your application. Thanks to croudet for this awesome contribution.

The module is also no longer regarded as experimental.

Micronaut Views 1.3 Update

Micronaut Views has been updated to and now features a new view renderer for Soy (Closure Templates). Thanks to Sam Gammon for this contribution.

Micronaut SQL 1.3 Update

Micronaut SQL includes the latest versions of Hibernate and adds support for the Vert.x MySQL and Postgres Clients. Thank you to shenzhou-6 for this contribution.

Micronaut Micrometer 1.3 Update

Micronaut Micrometer has been updated to support Micrometer 1.3.1.

Micronaut Kafka 1.4 Update

Micronaut Kafka 1.4 has been updated to support Kafka 2.4.0

Micronaut Neo4j 1.3 Update

Micronaut Neo4j 1.3 has been updated to support Neo4j Java Driver 1.7.5. In additional a new 2.0.0 version is available that supports Neo4j Java Driver 4.x line which is the latest version (in order to maintain semantic versioning the default is still 1.3 since the latest version includes changes to package names). See the Micronaut Neo4j Documentation for more information.

Micronaut GRPC 1.1 Update

Micronaut GRPC has been updated to the latest versions of GRPC and Protobuf.

@Requires OS

The ann:context.annotation.Requires[] annotation now has support for disabling beans based on the current operating system.

@Requires(os=Family.LINUX)

Basic Auth binding support

In the client and server, an argument of type api:http.BasicAuth[] can be used to generate or parse a basic authorization header.

@Post("/login")
String login(BasicAuth basicAuth) {
    ...
}

Request Certificate

For SSL requests, the certificate is now available as a request attribute. See api:http.HttpRequest#getCertificate--[HttpRequest#getCertificate]

Client Filter Matching By Annotation

Micronaut HTTP clients and client filters can now be matched by the presence of an annotation. Previously only URL matching was supported. See the documentation to get started.

Dependency Upgrades

Required Third Party Dependencies:

  • ASM 7.07.2

  • Caffeine 2.5.62.8.0

  • Jackson 2.9.92.10.1

  • Reactive Streams 1.0.21.0.3

Optional Third Party Dependencies:

  • Micrometer 1.2.11.3.1

  • Mongo Reactive Driver 1.11.01.13.0

  • Neo4j Java Driver 1.7.21.7.5

  • Jaeger 0.35.51.0.0

  • Kafka 2.3.02.4.0

  • Spring 5.1.85.2.3

  • Zipkin/Brave 5.6.55.9.0

  • Groovy 2.5.72.5.8

  • Gradle 5.5Gradle 6.1 (for new applications)

  • Hibernate Core 5.4.6.Final5.4.10.Final

Modules:

  • Micronaut GRPC 1.0.11.1.1

  • Micronaut Kafka 1.2.01.4.0

  • Micronaut Micrometer 1.2.11.3.0

  • Micronaut MongoDB 1.1.01.2.0

  • Micronaut MongoDB 1.1.01.3.0

  • Micronaut Neo4j 1.1.01.3.0

  • Micronaut OpenAPI 1.2.01.3.0

  • Micronaut Redis 1.1.01.2.0

  • Micronaut SQL 1.2.31.3.0

  • Micronaut Views 1.2.01.3.0

Micronaut Framework 1.2.9

1.2.9 Breaking Changes

  • The data format was changed for multiline server sent event data payloads to conform to the specification. Previously multiline data did not have the required data: prefix on each line and now it does.

Micronaut Framework 1.2.0

What’s new with 1.2.0

Support for GraalVM 19.3.0

Micronaut now supports creating native-images using GraalVM 19.3.0 for both JDK 8 and JDK 11.

Native Bean Validation Support

Hibernate Validator is no longer a required dependency to activate bean validation, with a new native implementation of Bean Validation available that is reflection free and supports reactive and AST level validations now available.

The micronaut-validation dependency is all that it is needed now and provides the following benefits over Hibernate Validator:

  • Reflection Free

  • Compile Time Computed Bean Metadata resulting in lower memory requirements

  • Reduction in JAR size by 2MB

  • Reduction in startup time by 300ms which was the cost of initializing Hibernate validator

  • Out-of-the-box GraalVM native image support

  • Reduction in GraalVM native image size by 10MB

Reactive Bean Validation Support

In previous versions of Micronaut manual validation had to be applied to reactive flows. You can now declare @Valid on method parameters that receive a reactive type and validation will automatically be applied.

Implicit @Validated and @Valid

It is no longer necessary to apply the ann:validation.Validated[] annotation to beans that accept @Valid arguments or use any javax.validation annotation.

Micronaut Kubernetes 1.0 Release

There is a new Micronaut Kubernetes module, with an improved support for running Micronaut applications in a Kubernetes cluster, including support for Kubernetes' ConfigMaps, Secrets and more.

To get started, use the kubernetes feature:

mn create-app my-app --features kubernetes

Micronaut Security 1.2 Update

Support for OAuth 2.0 and OpenID clients has been added to the Micronaut security module through a new dependency: micronaut-security-oauth2. It is now very easy to add support for login through an OAuth providers. See the Oauth section in the security documentation for more information.

Micronaut Micrometer 1.2 Update

Micronaut Micrometer has been updated to 1.2 which includes the following new features:

  • Update to Micrometer 1.2.0

  • Support for GraalVM native images

  • Meter registry support for AppOptics, Azure Monitor, Datadog, Dynatrace, Elastic, Ganglia, Humio, Influx, Jmx, Kairos, New Relic, SignalFX, Stackdriver and Wavefront

Thanks to Thiago Locatelli for this contribution.

Micronaut SQL 1.2 Update

The Micronaut SQL module has been updated with support for the following new features:

  • Improved Entity Scan support for JPA

  • Integration with Micronaut 1.2 Validator for JPA

  • GraalVM native-image metadata

  • Support for JOOQ. Thanks to Vladimir Kulev.

Micronaut Kafka 1.2 Update

The Micronaut Kafka module has been updated with support for the following new features:

  • Support for Kafka 2.3.0

  • Improved Exception Handling

  • Support for GraalVM native-image

Micronaut Rabbit 1.1.1 Update

The Micronaut RabbitMQ module has been updated with support for GraalVM native-image.

Micronaut Test 1.1 Update

The Micronaut Test module has been updated with support for the following new features:

  • Updated to JUnit 5.5

  • Support for Dependency Injection in Constructors and Methods for JUnit 5

  • Support for Kotlin Test

Optional Beans Returned from Factories

A ann:context.annotation.Factory[] bean can now return null if it is not possible to create the bean which will indicate to the dependency injection container that the bean does not exist. This allows for more complex logic within factory beans that can conditionally disable the bean if certain conditions are not met.

HashiCorp Vault Support

Initial support distributed configuration for HashiCorp Vault has been added. See the documentation on HashiCorp Vault Support for more information. Thanks to Thiago Locatelli for this contribution.

Oracle Cloud Support

Initial support for environment detection and cloud metadata for Oracle Cloud has been added. Thanks to Todd Sharp for this contribution.

@Client and Manual Service Discovery

If a service is configured statically with micronaut.http.services.*, it was previously not possible to override the configuration with the ann:http.client.annotation.Client[] annotation. It is now possible to override the configuration, which will result in a new client being created for the given client class.

Completable Support

The RxJava2 reactive type io.reactivex.Completable is now supported as a return type for controller and client methods.

Client and Server Host Resolution

New beans have been added to support lookup of the client address and the current server host. The implementations are aware of proxy headers and are configurable to look for custom headers. The api:http.server.util.HttpHostResolver[] can be injected to resolve the current server hostname and api:http.server.util.HttpClientAddressResolver[] can be injected to resolve the client address of the current request.

Default Implementation Support

When writing libraries for Micronaut, it is often the case that users will want to override part of your implementation. The most common way of doing so is creating custom beans that use the ann:context.annotation.Replaces[] annotation to replace your implementation. Because the ann:context.annotation.Replaces[] annotation requires a class argument to indicate which implementation to replace, it was required to make the implementation part of the public API. The class needed to be public because the user would need to reference the class directly in the annotation.

A new annotation has been added to solve this problem: ann:context.annotation.DefaultImplementation[]. See the section on Bean Replacements for more information.

HEAD Routes

For each route registered with the server that responds to GET requests, an additional route will be registered that responds to HEAD requests and will not include the body. This only applies to routes created by Micronaut through annotations. Any GET routes registered by custom route builders will not have corresponding HEAD routes added automatically.

Request Scope

A new bean scope has been created to allow for beans that only exist in the scope of a given HTTP request. See ann:runtime.http.scope.RequestScope[].

Environment Order and Priority

In previous versions of Micronaut, the property sources for an active environment had no priority over any other active environment. It was non deterministic which environment’s properties would override other environments. Now the last environment supplied has the highest priority. For example, if an application is started with -Dmicronaut.environments=first,second, application-second.yml will override properties in application-first.yml. This change affects all sources of properties, including distributed configuration sources.

Environment Endpoint

This version includes a new /env endpoint with information about the environment and its property sources See the documentation for more information.

RSS 2.0 Module Included in BOM

This version references the RSS configuration which eases the generation of a RSS 2.0 feeds in a Micronaut app.

Dependency Upgrades

  • Groovy 2.5.42.5.6

  • Gradle 5.1.1Gradle 5.5 (for new applications)

  • Micronaut SQL 1.1.11.2.0

  • Micronaut Micrometer 1.1.01.2.0

  • Micrometer 1.1.51.2.0

  • Micronaut Security 1.1.11.2.0

  • Micronaut Views 1.1.31.2.0

  • Micronaut Test 1.0.41.1.0

  • Netty 4.1.30.Final4.1.43.Final

  • Neo4j Driver 1.7.21.7.5

  • Mongo Driver 3.8.03.10.1

  • Mongo Reactive Streams 1.10.01.11.0

  • Kafka 2.1.12.3.0

  • Snake YAML 1.231.24

  • Lettuce 5.1.3.RELEASE5.1.7.RELEASE

  • JUnit 5.3.25.5.0

  • Picocli 3.5.24.0.1

  • Jaeger 0.33.10.35.5

  • Zipkin Reporter 2.8.42.10.0

  • Open Tracing 0.31.00.33.0

1.2.0 Breaking Changes

The following changes could potentially be considered to be breaking changes, however the likelihood of any negative impact is low.

  • The AWS distributed configuration through systems manager property store supported the notion of key=value in the value section of the configuration. This functionality has been removed because it did not consider properties that contain an = but are not in the format of key=value.

  • The return of reactive types with a generic of Void has been changed from always returning a 404 status to returning a 200, or whatever status is defined in the @Status annotation. This includes CompletionStage, RxJava2, and Reactor types. The change was made to be consistent with the behavior of methods that return void.

  • Extending a @ConfigurationProperties class that contains a @ConfigurationBuilder only allowed the builder to be configured through the child’s class prefix instead of the parent’s. This was a bug because the behavior is different compared to any other property on the parent class. Previously the parent.child.address prefix would have been used to configure the address builder on the child class. With this change parent.address will be used.

    @ConfigurationProperties("parent")
    class Parent {
        @ConfigurationBuilder(configurationPrefix = "address")
        ...
    }

    @ConfigurationProperties("child")
    class Child extends Parent {
    }

Micronaut Framework 1.1.0

What’s new with 1.1.0

GraalVM 19 Native Image Support

Micronaut 1.1.2 is the first version to support GraalVM 19’s native image changes.

Note
Although GraalVM 19 is the first official stable release of GraalVM, Substrate and the native-image tool remain in early adopter / experimental status. Therefore support for native images in Micronaut also remains experimental at this stage.

Modularization

Micronaut is now modular with parts of Micronaut being shifted into sub-projects. See the following links for new sub-projects that now have independent release cycles outside of Micronaut core:

File Watch and Server Restart

A new Automatic Restart feature is included that allows the server to restart if a change occurs to a file. This feature can be used both in production and at development time to achieve automatic application restarts when changing source code (when combined with a third party tool such as Gradle or Kubernetes in production).

Tip
Using the CLI
$ mn create-app my-app --features file-watch
$ cd my-app
$ ./gradlew run --continuous

GRPC Support

Support for creating GRPC + Micronaut applications has been added.

See the Micronaut GRPC documentation for more information and example applications.

Tip
Using the CLI

Use the CLI to quickly create a GRPC application.

mn create-app helloworld --profile grpc --lang java --build gradle

RabbitMQ Support

Support for creating Message-Driven Microservices with RabbitMQ has been added.

Tip
Using the CLI

Use the CLI to quickly create a RabbitMQ application.

mn create-app hellorabbit --features rabbitmq

See the Micronaut RabbitMQ documentation for more information.

GraphQL Support

Support for creating GraphQL + Micronaut applications has been added.

See the Micronaut GraphQL documentation for more information.

Compile Time Bean Introspection

A compilation time replacement for jdk:java.beans.Introspector[] has been added which allows introspecting and creating bean instances without using reflection, improving performance, memory consumption and GraalVM support.

See the new section on Bean Introspection for more information.

Cold Start and Performance Improvements

Micronaut 1.1 cold start performance has been improved through a variety of optimizations including compilation time indexing of common bean types. Users should see superior cold start performance for both Microservices and Functions.

AWS API Gateway Proxy Support

Support for AWS API Gateway Proxy has been added allowing AWS Lambda’s to be defined as regular controllers. See the documentation on AWS API Gateway Proxy Support for more information and links to examples.

Tip
Using the CLI
$ mn create-app my-app --features aws-api-gateway

GraalVM Native Improvements

Support for GraalVM Substrate (nativeimage) has been improved in a number of different ways.

  • Framework Improvements - Framework level dynamic classloading and reflection has been completely removed thus making it easier to get applications running on GraalVM nativeimage and reducing the number of customizations necessary.

  • Build Time Reflection Data - Thanks to the aforementioned feature, the older GraalClassLoadingAnalyzer runtime step has been removed and replaced by build time generation of reflection-config.json for classes that do require it (typically third party libraries).

  • Simplified Image Generation - You can now generate a native image with just native-image --class-path myjar.jar without any additional flags. Since Micronaut now computes the appropriate GraalVM configuration at compilation time.

Google Cloud Platform (GCP) Support

A new Google Cloud Configuration is available that adds general support for GCP and integration with Stackdriver Trace for distributed tracing.

AWS Lambda Custom Runtime + GraalVM Support

Support for creating AWS API Gateway applications (see above) that are compiled into GraalVM native images and run using an AWS Lambda Custom Runtime has been added. This reduces cold starts on Lambda to 100-200ms.

Tip
Using the CLI
$ mn create-app my-app --features aws-api-gateway-graal

AWS Lambda Alexa Skill Support

Support for creating Alexa Skills with Micronaut has been added.

Tip
Using the CLI

You can create Alexa functions with the CLI. Use the -lang parameter to specify java, kotlin or groovy.

$ mn create-function hello-alexa --provider alexa

Micronaut Test Templates

The CLI has been updated to generate tests that use Micronaut Test for JUnit 5 and Spock.

Micrometer 1.1 and @Timed Support

Micrometer has been upgraded to 1.1 and support for @Timed AOP advice added.

Tip
Using the CLI
$ mn create-app my-app --features micrometer

Kafka 2.1 and Kafka Improvements

Kafka support has been improved with the release of Micronaut Kafka 1.1 including supports for metrics, distributed tracing and Kafka 2.1.

API Versioning Support

API versioning is now supported. See the API Versioning documentation for more information on how to use this feature. Thanks for Bogdan Oros for contributing this feature.

Jackson @JsonView Support

Support for using @JsonView on controller methods has been added can be optionally enabled by setting jackson.json-view.enabled to true in application.yml. Thanks to Mark Mindenhall for contributing this feature.

Support for Spring Cloud Config Server

If you are already using Spring Config Server then Micronaut now features native integration for distributed configuration.

Thanks to Thiago Locatelli and Michel Schudel for contributing this feature.

Refactoring of File Responses

In an effort to make a more consistent and understandable API, some methods and classes related to sending file responses have been deprecated. api:http.server.types.files.SystemFile[] is the replacement for api:http.server.types.files.AttachedFile[] and the constructors of api:http.server.types.files.StreamedFile[] have been deprecated in favor of new constructors that better convey the intended functionality.

Note that api:http.server.types.files.SystemFile[] behaves differently from api:http.server.types.files.AttachedFile[] in that responses are by default sent inline instead of attached. In addition, support for sending attached responses has been added to api:http.server.types.files.StreamedFile[]. The following methods can be used to attach a system or streamed file.

  • api:http.server.types.files.StreamedFile#attach-java.lang.String-[StreamedFile#attach(String)]

  • api:http.server.types.files.SystemFile#attach--[SystemFile#attach()]

  • api:http.server.types.files.SystemFile#attach-java.lang.String-[SystemFile#attach(String)]

Support for Freemarker Views

Support for rendering Freemarker Views has been added. Thanks to Jeronimo López for contributing this feature.

Constraint Bean Support

For those using the micronaut-hibernate-validator configuration, constraints will now be attempted to be retrieved from the bean context. This means you can now use dependency injection in your custom constraints.

Support for JCache Caching

Support has been added for the JCache specification. If you define a javax.cache.CacheManager bean it will be used for caching. For example:

Using JCache Caching

snippet::io.micronaut.docs.whatsNew.CacheFactory[tags="imports,class"]

Support for JAsync SQL

Support for JAsync SQL has been added, which includes non-blocking drivers for both Postgres and MySQL. Thanks to Ohad Shai for contributing this feature.

Major Improvements for Multipart File Uploads

Several issues and improvements have been made in regards to file uploads in comparison to the previous version of Micronaut. These fixes have been substantial enough that they have caused the behavior of uploads to change, however these changes should not break any existing use cases. To summarize the issues:

  • Routes were not in control of the flow of bytes coming from the client with multipart uploads

  • It was not possible to read and release a chunk of data at a time. The entire upload would be put into memory or disk

  • Mixed (memory/disk with a threshold) uploads are not supported

The following changes have been implemented:

  • Routes gain control of the data flow as soon as they are executed. A route cannot be executed until all of its arguments are fulfilled, so data will reside on memory or disk until the route can be executed.

  • After processing a chunk of data it is immediately released. For memory uploads this means the data is immediately freed. For disk uploads the data remains on disk until after processing.

  • Two new configuration options are available to support mixed uploads: micronaut.server.multipart.mixed and micronaut.server.multipart.threshold. When data needs to be buffered, mixed uploads will initially store data in memory. Once the threshold is reached, the data will be erased from memory and moved entirely onto disk.

Option to Disable Environment Detection

Environment detection can be disabled through a method on the application context builder, system property, or evnironment variable.

See the Environment documentation for more information.

JWK and JWK Set support

You can expose an endpoint with a JWK Set thanks to the Keys Controller.

You can also make a remote JWKS participate in a JWT signature validation. Read the Validation with remote JWKS section to learn more.

Dependency Upgrades

  • Groovy 2.5.42.5.6

  • Gradle 4.10.25.1.1 (CLI Only)

  • Kafka 2.0.12.1.1

  • Micrometer 1.0.61.1.4

  • Reactive Streams 1.0.11.0.2

  • Jackson 2.9.72.9.8

  • Nimbus JOSE+JWT 6.0.26.8

  • Spring 5.0.10.RELEASE5.1.4.RELEASE

  • Reactor 3.2.0.RELEASE3.2.5.RELEASE

  • RxJava 2 2.2.22.2.6

  • Reactive Postgres 0.10.50.11.3

  • GORM 6.1.8.RELEASE7.0.0.RELEASE

  • Hibernate 5.3.7.Final5.4.0.Final

  • Hikari 2.7.93.3.1

  • Commons DBCP 2 2.1.12.6.0

  • Tomcat Pool 9.0.19.0.17

  • Neo4j Java Driver 1.6.41.7.2

  • Mongo Java Driver 3.8.03.10.0

  • Mongo Reactive Driver 1.8.01.10.0

  • Redis Lettuce Driver 5.0.4.RELEASE5.1.3.RELEASE

  • Jaeger 0.31.00.33.1

  • Zipkin Reporter 2.7.92.8.0

  • Brave Instrumentation HTTP 5.4.25.6.1

  • Brave Opentracing → 0.33.30.33.10

1.1.0 Breaking Changes

The following changes could potentially be considered to be breaking changes, however the likelihood of any negative impact is low.

  • HttpSessionConfiguration default value for cookiePath is /. The change was necessary for cookies to function normally.

  • The AccessRefreshToken API has been changed to include tokenType and expiresIn. This change was necessary to comply with the token response RFC 6749.

  • Route binding behavior for a request argument with a generic type has changed. For routes that take in an HttpRequest<SomeType>, an UnsatisfiedRouteException will be thrown if no body is found in the request. To restore the previous behavior, remove the generic type from the argument.

    public String hello(HttpRequest<Author> request) //requires the body to be present

    public String hello(HttpRequest request) //the body will not be read (same as 1.0.x)

Micronaut Framework 1.0.0

What’s new with 1.0.0

Modularization

Micronaut is now modular with parts of Micronaut being shifted into subprojects. See the following links for new subprojects that now have indepent release cycles outside of Micronaut core:

GraalVM 1.0 RC11 Support

The GraalVM support has been updated to accomodate the latest changes in GraalVM 1.0.0 RC11.

Dependency Upgrades

  • Kafka 2.0.02.0.1

  • Reactive Streams 1.0.11.0.2

  • Jackson 2.9.72.9.8

1.0.0 Breaking Changes

1.0.0.RC3

  • All Micronaut modules have been renamed to include micronaut- prefix to make it easier to manage dependencies. If you are upgrading rename all references modules. Example bommicronaut-bom, injectmicronaut-inject etc.

  • Methods for JWT signature generation have been removed from RSASignatureConfiguration or ECSignatureConfiguration. Those beans should be used in microservices where you need only signature verification and not generation.

To enable a RSA or EC JWT signature generation, you need to have in your app a bean of type RSASignatureGeneratorConfiguration or ECSignatureGeneratorConfiguration.

1.0.0.RC2

  • io.micronaut.security.authentication.Authenticator::authenticate method signature has changed from:

public Publisher<AuthenticationResponse> authenticate(UsernamePasswordCredentials credentials)

to:

public Publisher<AuthenticationResponse> authenticate(AuthenticationRequest authenticationRequest)

1.0.0.RC1

  • The default port if no port is specified is now port 8080 instead of a random port, except in the test environment. A random port can be obtained by setting the port to -1.

  • The configuration for static resource has been changed to allow multiple mappings, each with their own set of paths. This will allow accessing resources at multiple URLs. Previously the configuration might have looked like:

    micronaut:
        router:
            static:
                resources:
                    enabled: true
                    mapping: /static/**
                    paths:
                      - classpath:static

    And now the equivalent configuration would be:

    micronaut:
        router:
            static-resources:
                default:
                    enabled: true
                    mapping: /static/**
                    paths:
                      - classpath:static

    The word default in that example is arbitrary and can be replaced with any name that is appropriate to describe the category of resources that will be served.

    Note
    Notice the change from static.resources to static-resources.
  • The CLI feature for Netflix Archaius was incorrectly named netflix-archius. The feature has now been renamed to reflect the correct name, netflix-archaius.

  • The intercept url map security rule now no longer considers the query part of the request when determining if the request matches. Previously /?value=true would not match /.

  • Several APIs surrounding route URI matching and template parsing have changed to allow more information to be retrieved from the parsing process.

  • The following packages have been renamed:

    io.micronaut.http.server.binding -> io.micronaut.http.bind
  • The following annotations have been moved to new locations:

    io.micronaut.http.client.Client -> io.micronaut.http.client.annotation.Client
    io.micronaut.security.Secured -> io.micronaut.security.annotation.Secured
  • The jackson deserialization features ACCEPT_SINGLE_VALUE_AS_ARRAY and UNWRAP_SINGLE_VALUE_ARRAYS are now enabled by default. To revert to the previous behavior, see the section on Jackson Configuration for information on how to customize deserialization features.

1.0.0.M4

  • Libraries compiled against earlier versions of Micronaut are not binary compatible with this release.

  • The Java module names generated in previous versions were invalid because they contained a -. Module names with dashes were converted to an underscore. For example: io.micronaut.inject-javaio.micronaut.inject_java.

  • The annotation metadata API has been changed to no longer use reflective proxies for annotations. The methods that used to return the proxies now return an AnnotationValue that contains all of the data that existed in the proxy. The methods to create the proxies now exist under synthesize...

  • Many classes no longer implement AnnotatedElement.

  • AnnotationUtil has seen significant changes and is now marked as an internal class.

  • BeanContext.getBeanRegistrations has been renamed to BeanContext.getActiveBeanRegistrations.

  • Endpoint annotations have moved packages: io.micronaut.management.endpointio.micronaut.management.endpoint.annotation.

  • Endpoint method arguments were previously included in the route URI by default. Now endpoint arguments are not included in the route URI by default. An annotation, @Selector has been added to indicate an endpoint argument should be included in the URI.

  • The @Controller annotation now requires a value. Previously a convention was used to determine the URI.

  • The HttpMethodMapping annotations (@Get, @Put, etc) have changed their default behavior. They no longer use a convention based off the method name if the URI was not provided. The URI is still not required, however it now defaults to /. The new default means the method will be accessible from the controller URI.

1.0.0.M3

  • The contract for io.micronaut.http.codec.MediaTypeCodec has changed to support multiple media types.

  • To reduce confusion around @Parameter, it can no longer be used to denote an argument should be bound from the request url. Its sole purpose is defining arguments for parameterized beans. Use @QueryValue instead.

  • The health endpoint will now only report details when the user is authenticated. To revert to the previous behavior, set endpoints.health.detailsVisible: ANONYMOUS.

  • The CLI options have been standardized to use two leading dashes for long options (like --stacktrace) and one for shortcuts (like -h). That means that some options no longer work. For example, this command used to work with M2: create-app -lang groovy myapp. From M3, you will see this error: Could not convert 'ang' to SupportedLanguage for option '--lang'. Specifying either -l LANG or --lang LANG works as expected.

  • The following packages have been renamed:

    • io.micronaut.configurations.ribbonio.micronaut.configuration.ribbon

    • io.micronaut.configurations.hystrixio.micronaut.configuration.hystrix

    • io.micronaut.configurations.awsio.micronaut.configuration.aws

    • io.micronaut.http.netty.bufferio.micronaut.buffer.netty

  • The default Consul configuration prefix has been changed to reflect changes in the latest version of Consul. Previously a leading slash was expected and the default value was /config/. The new default value is config/. To restore the previous behavior, set consul.client.config.path = /config/

  • The session module will now serialize POJOs to JSON using Jackson by default instead of Java Serialization. This change is because Java serialization will be removed and deprecated in a future version of the JDK.

1.0.0.M2

  • The constructor signature for DefaultHttpClient has changed to include an extra argument. This change should not impact existing uses.

  • Libraries compiled against M1 are not binary compatible with M2.

  • For Java 9+ automatic module name has been set to <groupId>.<name>. Previously if you have been using the "inject-java" module, the module is now named "io.micronaut.inject-java".

  • When an HttpClientResponseException is thrown, the body of the response will be set to the exception message for responses with a text media type. Previously the status description was returned.

  • Mongo configurations were updated to a new version of the driver (3.6.1 → 3.7.1), which may break existing uses. See their upgrading page for more information.

  • The router configuration key was changed to be micronaut.router. Static resource configuration is affected by this change. Please update your configuration: router.static.resourcesmicronaut.router.static.resources.

Repository

You can find the source code of this project in this repository: