话不多说,先看问题
Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
//无法启动bean“documentationPluginsBootstrapper”;嵌套的异常是java。lang.NullPointerException
看看我的代码(什么都没写)
1.创建一个springboot文件,导入web依赖
2.导入依赖
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0</version>
</dependency>
3.写一个config配置swagger
@Configuration
@EnableSwagger2
public class SwaggerConfig {
}
4.编写TestController
@RestController
public class MyController {
@RequestMapping("/test")
public String test(){
return "hello,swagger";
}
}
5、访问测试 :启动不了,就报错
解决方案:
将swagger版本降级到2.9.2
将springBoot版本降级到2.5.2以后就可以了