问题描述,在玩swagger2的时候,由于出于好奇心,导入最新版的3.0.0,发现结果不对劲,访问页面404,最后找出原因并解决出来了;

有两种解决方案;第一种是降低版本,第二种不降低版本,导入其他的依赖和注解;

1)降低版本;使用3.0.0以下的版本即可;

相关依赖:

SpringFox 3.0.0(包含springfox-swagger2-3.0.0)——无法访问/swagger-ui.html解决方案
         https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui –>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>
        https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 &ndash;&gt;
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>-
SpringFox 3.0.0(包含springfox-swagger2-3.0.0)——无法访问/swagger-ui.html解决方案

相关注解:

SpringFox 3.0.0(包含springfox-swagger2-3.0.0)——无法访问/swagger-ui.html解决方案

 

 

 页面访问路径:

SpringFox 3.0.0(包含springfox-swagger2-3.0.0)——无法访问/swagger-ui.html解决方案

 

 

 2)第二种不降低版本,导入其他的依赖和注解;

相关依赖:(在这里,

springfox-swagger-ui和
springfox-swagger2这两个依赖要删除掉,不然还是访问不到页面,只留这一个依赖即可

SpringFox 3.0.0(包含springfox-swagger2-3.0.0)——无法访问/swagger-ui.html解决方案
        <!-- https://mvnrepository.com/artifact/io.springfox/springfox-boot-starter-->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-boot-starter</artifactId>
            <version>3.0.0</version>
        </dependency>
SpringFox 3.0.0(包含springfox-swagger2-3.0.0)——无法访问/swagger-ui.html解决方案

相关注解:注意,注解变了哦;

SpringFox 3.0.0(包含springfox-swagger2-3.0.0)——无法访问/swagger-ui.html解决方案

 

 页面访问路径(也改变了):http://localhost:8082/swagger-ui/index.html

SpringFox 3.0.0(包含springfox-swagger2-3.0.0)——无法访问/swagger-ui.html解决方案

 

相关文章:

  • 2021-07-14
  • 2022-02-08
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
  • 2021-06-12
猜你喜欢
  • 2021-11-07
  • 2022-01-23
  • 2022-12-23
  • 2021-04-24
  • 2022-12-23
  • 2021-06-18
相关资源
相似解决方案