Skip to content

Commit 147956a

Browse files
committed
Avoid creating multiple BeanNameViewResolver beans
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
1 parent ca15de4 commit 147956a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ public RequestContextFilter requestContextFilter() {
190190

191191
@Bean
192192
@ConditionalOnBean(View.class)
193+
@ConditionalOnMissingBean
193194
public BeanNameViewResolver beanNameViewResolver() {
194195
BeanNameViewResolver resolver = new BeanNameViewResolver();
195196
resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 10);

0 commit comments

Comments
 (0)