spring boot 2.6.0 使用swagger报 ‘documentationPluginsBootstrapper‘; java.lang.NullPointerException 错
Posted 程序员超时空
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring boot 2.6.0 使用swagger报 ‘documentationPluginsBootstrapper‘; java.lang.NullPointerException 错相关的知识,希望对你有一定的参考价值。
pom 配置如下
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
swagger 配置类
@Configuration
@EnableSwagger2
public class SwaggerConfig
@Bean
public Docket createRestApi()
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo()).select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
private ApiInfo apiInfo()
return new ApiInfoBuilder().build();
启动应用会报错
org.springframework.context.ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[spring-context-5.3.10.jar:5.3.10]
at org.springframework.context.support.DefaultLifecycleProcessor.accessKaTeX parse error: Undefined control sequence: \\[ at position 41: …ssor.java:54) ~\\̲[̲spring-context-…LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[spring-context-5.3.10.jar:5.3.10]
at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) ~[spring-context-5.3.10.jar:5.3.10]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) ~[spring-context-5.3.10.jar:5.3.10]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935) ~[spring-context-5.3.10.jar:5.3.10]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) ~[spring-context-5.3.10.jar:5.3.10]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.0-20211001.062147-315.jar:2.6.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:719) ~[spring-boot-2.6.0-20211001.062147-315.jar:2.6.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:401) ~[spring-boot-2.6.0-20211001.062147-315.jar:2.6.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[spring-boot-2.6.0-20211001.062147-315.jar:2.6.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) ~[spring-boot-2.6.0-20211001.062147-315.jar:2.6.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1279) ~[spring-boot-2.6.0-20211001.062147-315.jar:2.6.0-SNAPSHOT]
at com.wythe.mango.MangoApplication.main(MangoApplication.java:10) ~[classes/:na]
Caused by: java.lang.NullPointerException: 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$byPatternsConditionKaTeX parse error: Undefined control sequence: \\[ at position 23: …ings.java:89) ~\\̲[̲springfox-spi-3…comparing$77a9974fKaTeX parse error: Undefined control sequence: \\[ at position 25: …tor.java:469) ~\\̲[̲na:na\\] at ja…RefSortingSink.end(SortedOps.java:392) ~[na:na]
at java.base/java.util.stream.SinkKaTeX parse error: Undefined control sequence: \\[ at position 38: …ink.java:258) ~\\̲[̲na:na\\] at ja…ChainedReference.end(Sink.java:258) ~[na:na]
at java.base/java.util.stream.SinkKaTeX parse error: Undefined control sequence: \\[ at position 38: …ink.java:258) ~\\̲[̲na:na\\] at ja…ChainedReference.end(Sink.java:258) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) ~[na:na]
at springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider.requestHandlers(WebMvcRequestHandlerProvider.java:81) ~[springfox-spring-webmvc-3.0.0.jar:3.0.0]
at java.base/java.util.stream.ReferencePipeline$3KaTeX parse error: Undefined control sequence: \\[ at position 39: …ine.java:195) ~\\̲[̲na:na\\] at ja…ArrayListSpliterator.forEachRemaining(ArrayList.java:1654) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) ~[na:na]
at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.withDefaults(AbstractDocumentationPluginsBootstrapper.java:107) ~[springfox-spring-web-3.0.0.jar:3.0.0]
at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.buildContext(AbstractDocumentationPluginsBootstrapper.java:91) ~[springfox-spring-web-3.0.0.jar:3.0.0]
at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.bootstrapDocumentationPlugins(AbstractDocumentationPluginsBootstrapper.java:82) ~[springfox-spring-web-3.0.0.jar:3.0.0]
at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.start(DocumentationPluginsBootstrapper.java:100) ~[springfox-spring-web-3.0.0.jar:3.0.0]
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) ~[spring-context-5.3.10.jar:5.3.10]
… 14 common frames omitted
修复方法:注解 EnableSwagger2 改为EnableWebMvc
参考信息Springfox Reference Documentation
以上是关于spring boot 2.6.0 使用swagger报 ‘documentationPluginsBootstrapper‘; java.lang.NullPointerException 错的主要内容,如果未能解决你的问题,请参考以下文章
在 swagger UI 中生成示例示例(在 Spring boot 项目中)
@EnableAutoConfiguration(exclude =...) 在 Spring Boot 2.6.0 中的测试失败