- 1 Introduction
- 1.1 What’s New?
- Support for GraalVM 20.0.0
- Startup and Memory Usage Optimizations
- Micronaut Data Integration
- Initial Support for Kotlin Coroutines and Flow
- Immutable
@ConfigurationProperties
and@EachProperty
- Ability to Configure Log Levels via Properties
- New Micronaut Cache Modules
- New Micronaut Jackson XML Module
- Micronaut OpenAPI (Swagger) 1.3 Update
- Micronaut Views 1.3 Update
- Micronaut SQL 1.3 Update
- Micronaut Micrometer 1.3 Update
- Micronaut Kafka 1.4 Update
- Micronaut Neo4j 1.3 Update
- Micronaut GRPC 1.1 Update
- @Requires OS
- Basic Auth binding support
- Request Certificate
- Client Filter Matching By Annotation
- Dependency Upgrades
- 1.1 What’s New?
1 Introduction
Micronaut is a modern, JVM-based, full stack microservices framework designed for building modular, easily testable microservice applications.
Micronaut is developed by the creators of the Grails framework and takes inspiration from lessons learnt over the years building real-world applications from monoliths to microservices using Spring, Spring Boot and Grails.
Micronaut aims to provide all the tools necessary to build full-featured microservice applications, including:
Dependency Injection and Inversion of Control (IoC)
Sensible Defaults and Auto-Configuration
Configuration and Configuration Sharing
Service Discovery
HTTP Routing
HTTP Client with client-side load-balancing
At the same time Micronaut aims to avoid the downsides of frameworks like Spring, Spring Boot and Grails by providing:
Fast startup time
Reduced memory footprint
Minimal use of reflection
Minimal use of proxies
Easy unit testing
Historically, frameworks such as Spring and Grails were not designed to run in scenarios such as server-less functions, Android apps, or low memory-footprint microservices. In contrast, Micronaut is designed to be suitable for all of these scenarios.
This goal is achieved through the use of Java’s annotation processors, which are usable on any JVM language that supports them, as well as an HTTP Server and Client built on Netty. In order to provide a similar programming model to Spring and Grails, these annotation processors precompile the necessary metadata in order to perform DI, define AOP proxies and configure your application to run in a microservices environment.
Many of the APIs within Micronaut are heavily inspired by Spring and Grails. This is by design, and aids in bringing developers up to speed quickly.
1.1 What’s New?
Micronaut 1.3.7 includes the following changes:
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 @ConfigurationProperties has been added by annotating the constructor of any configuration class with @ConfigurationInject. See the documentation on Immutable Configuration for more information.
@ConfigurationProperties Example
import io.micronaut.context.annotation.ConfigurationProperties;
import io.micronaut.core.bind.annotation.Bindable;
import javax.validation.constraints.*;
import java.util.Optional;
@ConfigurationProperties("my.engine") (1)
public interface EngineConfig {
@Bindable(defaultValue = "Ford") (2)
@NotBlank (3)
String getManufacturer();
@Min(1L)
int getCylinders();
@NotNull
CrankShaft getCrankShaft(); (4)
@ConfigurationProperties("crank-shaft")
interface CrankShaft { (5)
Optional<Double> getRodLength(); (6)
}
}
@ConfigurationProperties Example
import io.micronaut.context.annotation.ConfigurationProperties
import io.micronaut.core.bind.annotation.Bindable
import javax.validation.constraints.*
@ConfigurationProperties("my.engine") (1)
interface EngineConfig {
@Bindable(defaultValue = "Ford") (2)
@NotBlank (3)
String getManufacturer()
@Min(1L)
int getCylinders()
@NotNull
CrankShaft getCrankShaft() (4)
@ConfigurationProperties("crank-shaft")
static interface CrankShaft { (5)
Optional<Double> getRodLength() (6)
}
}
@ConfigurationProperties Example
import io.micronaut.context.annotation.ConfigurationProperties
import io.micronaut.core.bind.annotation.Bindable
import javax.validation.constraints.*
import java.util.Optional
@ConfigurationProperties("my.engine") (1)
interface EngineConfig {
@get:Bindable(defaultValue = "Ford") (2)
@get:NotBlank (3)
val manufacturer: String
@get:Min(1L)
val cylinders: Int
@get:NotNull
val crankShaft: CrankShaft (4)
@ConfigurationProperties("crank-shaft")
interface CrankShaft { (5)
val rodLength: Double? (6)
}
}
1 | The @ConfigurationProperties annotation takes the configuration prefix and is declared on an interface |
2 | You can use @Bindable to set a default value if you want |
3 | Validation annotations can be used too |
4 | You can also specify references to other @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.
implementation("io.micronaut.xml:micronaut-jackson-xml")
<dependency>
<groupId>io.micronaut.xml</groupId>
<artifactId>micronaut-jackson-xml</artifactId>
</dependency>
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 @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 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 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.0
→7.2
Caffeine
2.5.6
→2.8.0
Jackson
2.9.9
→2.10.1
Reactive Streams
1.0.2
→1.0.3
Optional Third Party Dependencies:
Micrometer
1.2.1
→1.3.1
Mongo Reactive Driver
1.11.0
→1.13.0
Neo4j Java Driver
1.7.2
→1.7.5
Jaeger
0.35.5
→1.0.0
Kafka
2.3.0
→2.4.0
Spring
5.1.8
→5.2.3
Zipkin/Brave
5.6.5
→5.9.0
Groovy
2.5.7
→2.5.8
Gradle
5.5
→Gradle 6.1
(for new applications)Hibernate Core
5.4.6.Final
→5.4.10.Final
Modules:
Micronaut GRPC
1.0.1
→1.1.1
Micronaut Kafka
1.2.0
→1.4.0
Micronaut Micrometer
1.2.1
→1.3.0
Micronaut MongoDB
1.1.0
→1.2.0
Micronaut MongoDB
1.1.0
→1.3.0
Micronaut Neo4j
1.1.0
→1.3.0
Micronaut OpenAPI
1.2.0
→1.3.0
Micronaut Redis
1.1.0
→1.2.0
Micronaut SQL
1.2.3
→1.3.0
Micronaut Views
1.2.0
→1.3.0