Include WebMvcRegistrations beans in WebMvcTest

See gh-27823
This commit is contained in:
Yanming Zhou
2021-08-27 14:18:29 +08:00
committed by Stephane Nicoll
parent 0fed29d440
commit 6e9bdacc10
3 changed files with 15 additions and 1 deletions

View File

@@ -368,7 +368,7 @@ include::{docs-java}/features/testing/springbootapplications/jsontests/MyJsonAss
[[features.testing.spring-boot-applications.spring-mvc-tests]]
==== Auto-configured Spring MVC Tests
To test whether Spring MVC controllers are working as expected, use the `@WebMvcTest` annotation.
`@WebMvcTest` auto-configures the Spring MVC infrastructure and limits scanned beans to `@Controller`, `@ControllerAdvice`, `@JsonComponent`, `Converter`, `GenericConverter`, `Filter`, `HandlerInterceptor`, `WebMvcConfigurer`, and `HandlerMethodArgumentResolver`.
`@WebMvcTest` auto-configures the Spring MVC infrastructure and limits scanned beans to `@Controller`, `@ControllerAdvice`, `@JsonComponent`, `Converter`, `GenericConverter`, `Filter`, `HandlerInterceptor`, `WebMvcConfigurer`, `WebMvcRegistrations`, and `HandlerMethodArgumentResolver`.
Regular `@Component` and `@ConfigurationProperties` beans are not scanned when the `@WebMvcTest` annotation is used.
`@EnableConfigurationProperties` can be used to include `@ConfigurationProperties` beans.