SpringBoot集成Swagger3.0使用


SpringBoot集成Swagger3.0使用

一、pom文件導入依賴

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

二、啟動文件添加@EnableOpenApi

@EnableOpenApi
@SpringBootApplication
public class DemoApplication {
 
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
 
}

三、啟動訪問路徑:http://localhost:9001/swagger-ui/index.html

備注:端口不一定要和我一樣

注意點

這次更新,移除了原來默認的swagger頁面路徑:http://host/context-path/swagger-ui.html,

新增了兩個可訪問路徑:

  1. http://host/context-path/swagger-ui/index.html
  2. http://host/context-path/swagger-ui/

通過調整日志級別,還可以看到新版本的swagger文檔接口也有新增,除了以前老版本的文檔接口/v2/api-docs之外,還多了一個新版本的/v3/api-docs接口。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM