From 537b0c3ff345ea75b5ea5cda5e9c9eb6f6dbab69 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Wed, 30 Apr 2014 15:58:46 +0100 Subject: [PATCH] Use enum for MessageCodesResolver format Fixes gh-670 --- .../boot/autoconfigure/web/WebMvcAutoConfiguration.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java index e6b9c503e5..434f1397a2 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java @@ -31,6 +31,7 @@ import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; @@ -137,7 +138,7 @@ public class WebMvcAutoConfiguration { private Integer cachePeriod; @Value("${spring.mvc.message-codes-resolver.format:}") - private String messageCodesResolverFormat = ""; + private DefaultMessageCodesResolver.Format messageCodesResolverFormat = null; @Value("${spring.mvc.locale:}") private String locale = ""; @@ -204,10 +205,10 @@ public class WebMvcAutoConfiguration { @ConditionalOnExpression("'${spring.mvc.message-codes-resolver.format:}' != ''") public MessageCodesResolver messageCodesResolver() { DefaultMessageCodesResolver resolver = new DefaultMessageCodesResolver(); - resolver.setMessageCodeFormatter(DefaultMessageCodesResolver.Format.valueOf(messageCodesResolverFormat)); + resolver.setMessageCodeFormatter(this.messageCodesResolverFormat); return resolver; } - + @Override public void addFormatters(FormatterRegistry registry) { for (Converter converter : getBeansOfType(Converter.class)) {