美文网首页
Spring restful Swagger设置

Spring restful Swagger设置

作者: 寻找无名的特质 | 来源:发表于2023-01-05 06: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
实践证明,不需要编写过多的配置代码,配置代码只是增加说明信息,如果只是进行接口测试,直接访问就可用。

相关文章

网友评论

      本文标题:Spring restful Swagger设置

      本文链接:https://www.haomeiwen.com/subject/bupdqdtx.html