0

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\]
3
  • can you share your project pom file? You are probably missing a dependency or a configuration since the underlying exceptions says Caused by: java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null Commented Sep 28, 2023 at 19:54
  • take a look at: stackoverflow.com/questions/72235752/… Commented Sep 28, 2023 at 20:12
  • It's done, I should add spring.mvc.pathmatch.matching-strategy=ant_path_matcher to the application.properties. Thank you! Commented Oct 2, 2023 at 6:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.