From 549d4f7fbe488a5d9df8339d5f72c029d3d08309 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Sat, 30 Jan 2021 17:01:44 -0800 Subject: [PATCH] Document that Spring MVC has own ConversionService Update documentation to make it clearer that Spring MVC does not use the `ApplicationConversionService` unless configured explicitly. Closes gh-22718 --- .../src/docs/asciidoc/spring-boot-features.adoc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc index 0ae5b08e4d4a..660b91fd518e 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc @@ -2271,6 +2271,16 @@ If you want to provide custom instances of `RequestMappingHandlerMapping`, `Requ If you want to take complete control of Spring MVC, you can add your own `@Configuration` annotated with `@EnableWebMvc`, or alternatively add your own `@Configuration`-annotated `DelegatingWebMvcConfiguration` as described in the Javadoc of `@EnableWebMvc`. +[NOTE] +==== +Spring MVC uses a different `ConversionService` to the one used to convert values from your `application.properties` or `application.yaml` file. +The means that `Period`, `Duration` and `DataSize` converters are not available and that `@DurationUnit` and `@DataSizeUnit` annotations will be ignored. + +If you want to customize the `ConversionService` used by Spring MVC, you can provide a `WebMvcConfigurer` bean with an `addFormatters` method. +From this method you can register any converter that you like, or you can delegate to the static methods available on `ApplicationConversionService`. +==== + + [[boot-features-spring-mvc-message-converters]] ==== HttpMessageConverters