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.forEa