8

如何使用 Spring Boot 进行 Swagger UI 3 设置?

 2 years ago
source link: https://www.jdon.com/56938
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
如何使用 Spring Boot 进行 Swagger UI 3 设置?

打开 pom.xml 并添加这些依赖项

<!-- 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>
  • 使用 Swagger 3,您无需添加 Docket 配置或使用 @EnableSwagger2 注释。一切都由 Springfox-boot-starter 处理,我们刚刚在上面的 pom.xml 中添加了它。

就是这样。完毕!运行 Spring Boot 应用程序主类并在浏览器中点击以下 URL。

http://localhost:8080/swagger-ui/

请注意上面 URL 中的更改。现在不需要是swagger-ui.html,还要注意localhost URL 末尾的结尾正斜杠(“/”)。

Github 上提供的代码 – https://github.com/webfuse2017/wf-spring-poc/


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK