Micronaut features some built-in conversions that are useful, which are detailed below.
Durations can be specified by appending the unit with a number. Supported units are , ms
, m
etc. The following table summarizes examples:
For example to configure the default HTTP client read timeout:
Using Duration Values
Lists and arrays can be specified in Java properties files as comma-separated values or in YAML using native YAML lists. The generic types are used to convert the values. For example in YAML:
Specifying lists or arrays in YAML
my:
integers:
- 1
- 2
urls:
- http://foo.com
Or in Java properties file format:
Specifying lists or arrays in Java properties comma-separated
Alternatively you can use an index:
Specifying lists or arrays in Java properties using index
my.app.integers[1]=2
For the above example configurations you can define properties to bind to with the target type supplied via generics:
Using @ReadableBytes
public void setMaxContentLength(@ReadableBytes int maxContentLength) {
this.maxContentLength = maxContentLength;
}
With the above in place you can set micronaut.http.client.max-content-length
using the following values:
Configuration Value | Resulting Value |
---|---|
| 10 megabytes |
| 10 kilobytes |
| 10 gigabytes |
| A raw byte length |
The annotation can be used on any setter to allow the date format to be specified when binding java.time
date objects.
Using for Dates