簡記 SpringBoot禁用Swagger

2022-09-19 12:24:14 字數 682 閱讀 4372

swagger是 j**a web 開發中常用的介面文件生成類庫,在開發和前後端聯調時使用它來模擬介面呼叫能提高開發效率。但是,在生產環境可能並不需要它,乙個原因是啟用它會延長程式啟動時間(動態解析**中的註解來生成文件),另乙個是安全問題(過不了漏洞掃瞄,需要鑑權訪問或禁用掉)

本文的目標就是禁用掉swagger,由於配置比較簡單,筆者在本地已經實踐通過了,直接記錄在這裡了。

筆者測試版本基於 springboot 2.4.6 +io.springfox:springfox-swagger2:3.0.0

springfox:

documentation:

auto-startup: false

springfox.documentation.auto-startup=false
說是最佳實踐,其實是相對而言的。即通過springboot的配置覆蓋/多環境配置檔案來實現。

springfox.documentation.auto-startup=true
以上兩種方式都可以,看大家想使用哪種了。

springboot 如何禁用某項健康檢查

management.health.mail.enabled management.healthwww.cppcns.com.mongo.enabled managemeycoyomdent.health.redis.enabled management.health.solr.enabled ma...

在k8s上部署Springboot

建立service使用者訪問 訪問springboot專案的介面 在教程開始前,大家需要先搭建好k8s集群 harbor私有倉庫和構建自己的springboot映象,可以參考以下文章 使用kubeadm搭建 kubernetes k8s集群 harbor 安裝 dockerfile構建springb...

Springboot啟動初始化資料,執行sql指令碼

純配置。最方便簡潔,是最優選擇。yml檔案 spring datasource schema classpath schema.sql data classpath data.sql initialization mode always再在resource目錄下新增schema.sql和data.s...