I am beginner in Spring and I need help with that issue. That problem it's when I use @EnableSwagger2 adnotation.
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableSwagger2
@Configuration
@RequiredArgsConstructor
public class Config {
private final ObjectMapper objectMapper;
void customizeObjectMapper() {
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
}
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2023-09-28T21:12:11.549+02:00 ERROR 25124 --- \[ main\] o.s.boot.SpringApplication : Application run failed
org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:182) \~\[spring-context-6.0.12.jar:6.0.12\]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:357) \~\[spring-context-6.0.12.jar:6.0.12\]
at java.base/java.lang.Iterable.forEach(Iterable.java:75) \~\[na:na\]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:156) \~\[spring-context-6.0.12.jar:6.0.12\]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:124) \~\[spring-context-6.0.12.jar:6.0.12\]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:958) \~\[spring-context-6.0.12.jar:6.0.12\]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:611) \~\[spring-context-6.0.12.jar:6.0.12\]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) \~\[spring-boot-3.1.4.jar:3.1.4\]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) \~\[spring-boot-3.1.4.jar:3.1.4\]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439) \~\[spring-boot-3.1.4.jar:3.1.4\]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) \~\[spring-boot-3.1.4.jar:3.1.4\]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309) \~\[spring-boot-3.1.4.jar:3.1.4\]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298) \~\[spring-boot-3.1.4.jar:3.1.4\]
at com.example.spring_learn_with_yt_1.SpringLearnWithYt1Application.main(SpringLearnWithYt1Application.java:10) \~\[classes/:na\]
Caused by: java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null
at springfox.documentation.spring.web.WebMvcPatternsRequestConditionWrapper.getPatterns(WebMvcPatternsRequestConditionWrapper.java:56) \~\[springfox-spring-webmvc-3.0.0.jar:3.0.0\]
at springfox.documentation.RequestHandler.sortedPaths(RequestHandler.java:113) \~\[springfox-core-3.0.0.jar:3.0.0\]
at springfox.documentation.spi.service.contexts.Orderings.lambda$byPatternsCondition$3(Orderings.java:89) \~\[springfox-spi-3.0.0.jar:3.0.0\]
Caused by: java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is nullspring.mvc.pathmatch.matching-strategy=ant_path_matcherto the application.properties. Thank you!