Failed to start bean ‘documentationPluginsBootstrapper‘; nested exception is NullPointerException

SringBoot项目中报错:

1)Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException

2)at com.hucj.timetrip.TimeTripApplication.main(TimeTripApplication.java:12) [classes/:na]

3)Caused by: java.lang.NullPointerException: null

此问题发生在启动类,不能启动。

原因:版本的不同所带来的一些改变,Swagger2WebMvc问题

解决:

1. 方法一:添加 @EnableWebMvc 注解 

如:

@SpringBootApplication
@EnableWebMvc
public class TimeTripApplication {

    public static void main(String[] args) {
        SpringApplication.run(TimeTripApplication.class, args);
    }
}

springboot2.6及以上 会出现上述报错;

扫描二维码关注公众号,回复: 15345094 查看本文章

弊端:使用较新版本的SpringBoot时其他插件和java代码库可能不能及时更新以适应版本,如Knife4j2.0.9在高版本下将无法使用

2.方法二:退回版本2.6以下

在parent中修改依赖的版本

 <parent>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-parent</artifactId>
     <version>2.5.9</version>
     <relativePath/> 
 </parent>

猜你喜欢

转载自blog.csdn.net/qq_43780761/article/details/126456774
今日推荐