From 147956a7b211ba53d6b1d573a867c102945f65f1 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 5 May 2016 16:10:36 +0100 Subject: [PATCH] Avoid creating multiple BeanNameViewResolver beans MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ErrorMvcAutoConfiguration creates a BeanNameViewResolver bean in case the user has used @EnabledWebMvc and disabled WebMvcAutoConfiguration. If the user hasn’t used @EnabledWebMvc, WebMvcAutoConfiguration will creates its BeanNameViewResolver and override the one that’s already been defined by ErrorMvcAutoConfiguration. This commit makes WebMvcAutoConfiguration’s BeanNameViewResolver definition conditional on there being no existing BeanNameViewResolver bean definition. Closes gh-5354 --- .../boot/autoconfigure/web/WebMvcAutoConfiguration.java | 1 + 1 file changed, 1 insertion(+) 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 b70565a09c..bfa1adf029 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 @@ -190,6 +190,7 @@ public class WebMvcAutoConfiguration { @Bean @ConditionalOnBean(View.class) + @ConditionalOnMissingBean public BeanNameViewResolver beanNameViewResolver() { BeanNameViewResolver resolver = new BeanNameViewResolver(); resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 10);