Merge pull request #44259 from nosan
* pr/44259: Polish "Do not auto-configure ViewResolver if spring-webmvc is absent" Do not auto-configure ViewResolver if spring-webmvc is absent Closes gh-44259
This commit is contained in:
commit
d9c54312d8
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -56,6 +56,7 @@ import org.springframework.security.web.server.csrf.CsrfToken;
|
||||||
import org.springframework.util.MimeType;
|
import org.springframework.util.MimeType;
|
||||||
import org.springframework.util.unit.DataSize;
|
import org.springframework.util.unit.DataSize;
|
||||||
import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter;
|
import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter;
|
||||||
|
import org.springframework.web.servlet.view.AbstractCachingViewResolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link EnableAutoConfiguration Auto-configuration} for Thymeleaf.
|
* {@link EnableAutoConfiguration Auto-configuration} for Thymeleaf.
|
||||||
|
@ -142,6 +143,7 @@ public class ThymeleafAutoConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration(proxyBeanMethods = false)
|
@Configuration(proxyBeanMethods = false)
|
||||||
|
@ConditionalOnClass(AbstractCachingViewResolver.class)
|
||||||
static class ThymeleafViewResolverConfiguration {
|
static class ThymeleafViewResolverConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -60,6 +60,7 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||||
import org.springframework.web.servlet.ViewResolver;
|
import org.springframework.web.servlet.ViewResolver;
|
||||||
import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter;
|
import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter;
|
||||||
import org.springframework.web.servlet.support.RequestContext;
|
import org.springframework.web.servlet.support.RequestContext;
|
||||||
|
import org.springframework.web.servlet.view.AbstractCachingViewResolver;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
@ -336,6 +337,12 @@ class ThymeleafServletAutoConfigurationTests {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void missingAbstractCachingViewResolver() {
|
||||||
|
this.contextRunner.withClassLoader(new FilteredClassLoader(AbstractCachingViewResolver.class))
|
||||||
|
.run((context) -> assertThat(context).hasNotFailed().doesNotHaveBean("thymeleafViewResolver"));
|
||||||
|
}
|
||||||
|
|
||||||
@Configuration(proxyBeanMethods = false)
|
@Configuration(proxyBeanMethods = false)
|
||||||
static class LayoutDialectConfiguration {
|
static class LayoutDialectConfiguration {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue