Allow user to opt out of ContentNegotiatingViewResolver

The bean ID for the ContentNegotiatingViewResolver is now
"viewResolver" (it is the *one*). The conditions have been changed
so that a user only has to define a bean of the same name to switch
it off.

Fixes gh-546
This commit is contained in:
Dave Syer
2014-03-22 14:44:30 +00:00
parent 4637c2a8f7
commit 373e2c5156
3 changed files with 7 additions and 8 deletions

View File

@@ -182,9 +182,9 @@ public class ThymeleafAutoConfiguration {
"excludedViewNames", String[].class));
resolver.setViewNames(this.environment.getProperty("viewNames",
String[].class));
// Needs to come before any fallback resolver (e.g. a
// InternalResourceViewResolver)
resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 20);
// This resolver acts as a fallback resolver (e.g. like a
// InternalResourceViewResolver) so it needs to have low precedence
resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 5);
return resolver;
}

View File

@@ -179,8 +179,8 @@ public class WebMvcAutoConfiguration {
@Bean
@ConditionalOnBean(ViewResolver.class)
public ContentNegotiatingViewResolver contentNegotiatingViewResolver(
BeanFactory beanFactory) {
@ConditionalOnMissingBean(name = "viewResolver")
public ContentNegotiatingViewResolver viewResolver(BeanFactory beanFactory) {
ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();
resolver.setContentNegotiationManager(beanFactory
.getBean(ContentNegotiationManager.class));