Spring restful Swagger设置

2023-01-05  本文已影响0人  寻找无名的特质

在Spring restful项目中设置Swagger很简单,只有增加依赖项就可用了:

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-boot-starter</artifactId>
            <version>3.0.0</version>
        </dependency>

运行项目,会发现出现错误:

Failed to start bean 'documentationPluginsBootstrapper

这个错误是springfox-boot-starter中的一个bug,需要在application.properites增加如下设置:
spring.mvc.pathmatch.matching-strategy=ant-path-matcher
再次运行项目,错误消失,然后可用访问swagger的页面:http://localhost:8080/swagger-ui/index.html
实践证明,不需要编写过多的配置代码,配置代码只是增加说明信息,如果只是进行接口测试,直接访问就可用。

上一篇 下一篇

猜你喜欢

热点阅读