diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java index d930e4e066..979e9f6823 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -59,6 +59,8 @@ import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.GenericTypeResolver; import org.springframework.core.annotation.AnnotationAwareOrderComparator; +import org.springframework.core.convert.ConversionService; +import org.springframework.core.convert.support.ConfigurableConversionService; import org.springframework.core.env.CommandLinePropertySource; import org.springframework.core.env.CompositePropertySource; import org.springframework.core.env.ConfigurableEnvironment; @@ -480,8 +482,10 @@ public class SpringApplication { protected void configureEnvironment(ConfigurableEnvironment environment, String[] args) { if (this.addConversionService) { + ConversionService conversionService = ApplicationConversionService + .getSharedInstance(); environment.setConversionService( - ApplicationConversionService.getSharedInstance()); + (ConfigurableConversionService) conversionService); } configurePropertySources(environment, args); configureProfiles(environment, args); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/ApplicationConversionService.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/ApplicationConversionService.java index e1d9ec482c..919b272547 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/ApplicationConversionService.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/ApplicationConversionService.java @@ -53,12 +53,16 @@ public class ApplicationConversionService extends FormattingConversionService { } /** - * Return a shared default {@code ApplicationConversionService} instance, lazily + * Return a shared default application {@code ConversionService} instance, lazily * building it once needed. + *
+ * Note: This method actually returns an {@link ApplicationConversionService} + * instance. However, the {@code ConversionService} signature has been preserved for + * binary compatibility. * @return the shared {@code ApplicationConversionService} instance (never * {@code null}) */ - public static ApplicationConversionService getSharedInstance() { + public static ConversionService getSharedInstance() { ApplicationConversionService sharedInstance = ApplicationConversionService.sharedInstance; if (sharedInstance == null) { synchronized (ApplicationConversionService.class) {