From 9327b18036d658bc8a88f1a77d4f4d70446cef85 Mon Sep 17 00:00:00 2001 From: ralf-ueberfuhr-ars <67416181+ralf-ueberfuhr-ars@users.noreply.github.com> Date: Fri, 27 May 2022 14:20:27 +0200 Subject: [PATCH] Insert hint for WebMvcTest configuration --- problem-spring-web/README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/problem-spring-web/README.md b/problem-spring-web/README.md index 66444dad..997f1c69 100644 --- a/problem-spring-web/README.md +++ b/problem-spring-web/README.md @@ -31,7 +31,7 @@ If you're not using Spring Boot, add the following dependency to your project: ## Configuration -If not using the starter module, make sure you register the required modules with your ObjectMapper: +If not using the starter module, make sure you register the required Jackson Modules with your ObjectMapper: ```java @Bean @@ -45,6 +45,18 @@ public ConstraintViolationProblemModule constraintViolationProblemModule() { } ``` +If using the starter module, but disabling Spring Boot AutoConfiguration, you could easily import the `ProblemJacksonAutoConfiguration` class. +For example, this is necessary when writing tests and use `@WebMvcTest` instead of `@SpringBootTest`: + +```java +@WebMvcTest +@ContextConfiguration(classes = ...) +@Import(ProblemJacksonAutoConfiguration.class) +class MyTest { + // ... +} +``` + The following table shows all built-in advice traits: | Advice Trait | Produces |