代码编织梦想

             <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger2</artifactId>
                <version>2.9.2</version>
            </dependency>
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger-ui</artifactId>
                <version>2.9.2</version>
            </dependency>

在引入正确的依赖后,在主类上加入了@EnableSwagger2注解,后来就报空指针异常

 

原因:Springfox使用的路径匹配基于AntPathMatcher,而Spring Boot 2.6.X使用的是PathPatternMatcher

解决方法就是在application.yml文件中设置

spring:
  mvc:
    pathmatch:
      matching-strategy: ant_path_matcher

 

 最后成功打开接口文档

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_43735076/article/details/129824796

空指针异常exception in thread “main“ java.lang.nullpointerexception_我会蒸馒头的博客-爱代码爱编程

  目录 例子: 实体类:  主程序 解决方法: map=new HashMap()和map=null的区别 引入:JVM内存机制 引入:HashMap结构 例子: 实体类:  public class Cat { private String name="招财猫"; public Integer age=10;