禁用方法1:
======
使用注解 @Value() 推薦使用
package com.dc.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
-
@author sunny chen
-
@version V1.0
-
@Package com.dc.config
-
@date 2018/1/16 17:33
-
@Description: 主要用途:開啟在線接口文檔和添加相關配置
*/
@Configuration
@EnableSwagger2
public class Swagger2Config extends WebMvcConfigurerAdapter {
@Value(“${swagger.enable}”)
private Boolean enable;
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.enable(enable)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage(“com.dc.controller”))
.paths(PathSelectors.any())
//.paths(PathSelectors.none())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title(“auth系統(tǒng)數(shù)據(jù)接口文檔”)
.description(“此系統(tǒng)為新架構(gòu)Api說明文檔”)
.termsOfServiceUrl(“”)
.contact(new Contact(“陳永佳 chen867647213@163.com”, “”, “https://blog.csdn.net/Mrs_chens”))
.version(“1.0”)
.build();
}
/**
-
swagger ui資源映射
-
@param registry
*/
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler(“swagger-ui.html”)
.addResourceLocations(“classpath:/META-INF/resources/”);
registry.addResourceHandler(“/webjars/**”)
.addResourceLocations(“classpath:/META-INF/resources/webjars/”);
}
/**
-
swagger-ui.html路徑映射,瀏覽器中使用/api-docs訪問
-
@param registry
*/
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addRedirectViewController(“/api-docs”,“/swagger-ui.html”);
}
}
禁用方法2:
======
使用注解 @Profile({“dev”,“test”}) 表示在開發(fā)或測試環(huán)境開啟,而在生產(chǎn)關閉。(推薦使用)
package com.dc.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
-
@author sunny chen
-
@version V1.0
-
@Package com.dc.config
-
@date 2018/1/16 17:33
-
@Description: 主要用途:開啟在線接口文檔和添加相關配置
*/
@Configuration
@EnableSwagger2
@Profile({“dev”,“test”})
public class Swagger2Config extends WebMvcConfigurerAdapter {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage(“com.dc.controller”))
.paths(PathSelectors.any())
//.paths(PathSelectors.none())
.build();
}
小編13年上海交大畢業(yè),曾經(jīng)在小公司待過,也去過華為、OPPO等大廠,18年進入阿里一直到現(xiàn)在。
深知大多數(shù)初中級Java工程師,想要提升技能,往往是自己摸索成長,但自己不成體系的自學效果低效又漫長,而且極易碰到天花板技術停滯不前!
因此收集整理了一份《2024年最新Java開發(fā)全套學習資料》送給大家,初衷也很簡單,就是希望能夠幫助到想自學提升又不知道該從何學起的朋友,同時減輕大家的負擔。
由于文件比較大,這里只是將部分目錄截圖出來,每個節(jié)點里面都包含大廠面經(jīng)、學習筆記、源碼講義、實戰(zhàn)項目、講解視頻
如果你覺得這些內(nèi)容對你有幫助,可以添加下面V無償領?。。▊渥ava)
總結(jié):繪上一張Kakfa架構(gòu)思維大綱腦圖(xmind)
其實關于Kafka,能問的問題實在是太多了,扒了幾天,最終篩選出44問:基礎篇17問、進階篇15問、高級篇12問,個個直戳痛點,不知道如果你不著急看答案,又能答出幾個呢?
若是對Kafka的知識還回憶不起來,不妨先看我手繪的知識總結(jié)腦圖(xmind不能上傳,文章里用的是圖片版)進行整體架構(gòu)的梳理
梳理了知識,刷完了面試,如若你還想進一步的深入學習解讀kafka以及源碼,那么接下來的這份《手寫“kafka”》將會是個不錯的選擇。
-
Kafka入門
-
為什么選擇Kafka
-
Kafka的安裝、管理和配置
-
Kafka的集群
-
第一個Kafka程序
-
Kafka的生產(chǎn)者
-
Kafka的消費者
-
深入理解Kafka
-
可靠的數(shù)據(jù)傳遞
-
Spring和Kafka的整合
-
SpringBoot和Kafka的整合
-
Kafka實戰(zhàn)之削峰填谷
-
數(shù)據(jù)管道和流式處理(了解即可)
門
-
為什么選擇Kafka
-
Kafka的安裝、管理和配置
-
Kafka的集群
-
第一個Kafka程序
-
Kafka的生產(chǎn)者
-
Kafka的消費者
-
深入理解Kafka
-
可靠的數(shù)據(jù)傳遞
-
Spring和Kafka的整合
-
SpringBoot和Kafka的整合
-
Kafka實戰(zhàn)之削峰填谷
-
數(shù)據(jù)管道和流式處理(了解即可)
[外鏈圖片轉(zhuǎn)存中…(img-EtDGiJOw-1710739095135)]
[外鏈圖片轉(zhuǎn)存中…(img-HOexjWxt-1710739095135)]文章來源:http://www.zghlxwxcb.cn/news/detail-855448.html
本文已被CODING開源項目:【一線大廠Java面試題解析+核心總結(jié)學習筆記+最新講解視頻+實戰(zhàn)項目源碼】收錄文章來源地址http://www.zghlxwxcb.cn/news/detail-855448.html
到了這里,關于Spring Boot 禁用 Swagger 的三種方式的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!