国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術文章
文章詳情頁

解決spring boot網關gateway導致的坑,無法下載文件問題

瀏覽:4日期:2023-07-02 08:06:23
話不多說,直接上圖

解決spring boot網關gateway導致的坑,無法下載文件問題

接口返回內容,瀏覽器顯示PDF文檔。但是輸入接口地址以后一直提示這個

解決spring boot網關gateway導致的坑,無法下載文件問題

核對接口路徑也是正確的,并且沒有報錯提示,后面發現是網關沒有配置放行路徑,于是進行了補充

解決spring boot網關gateway導致的坑,無法下載文件問題

所以 以后對于前端請求統一由網關進行配置處理的,一定要對于靜態資源合理配置,或者對于放行接口要統一補充進來(最后統一一下下接口前綴名稱,這樣就只需要寫一個了)

下面我再說一個坑:

spring cloud gateway啟動報錯:org.springframework.cloud.gateway.config.GatewayAutoConfiguration

springcloud 啟動一直報錯 詳細錯誤信息

Parameter 0 of method modifyRequestBodyGatewayFilterFactory in org.springframework.cloud.gateway.config.GatewayAutoConfiguration required a bean of type ’org.springframework.http.codec.ServerCodecConfigurer’ that could not be found.

Action:

Consider defining a bean of type ’org.springframework.http.codec.ServerCodecConfigurer’ in your configuration.

解決辦法

將pom文件中的spring-boot-starter-web 移除

詳細分析

點進去 GatewayAutoConfiguration 這個類

@Beanpublic ModifyRequestBodyGatewayFilterFactory modifyRequestBodyGatewayFilterFactory(ServerCodecConfigurer codecConfigurer) { return new ModifyRequestBodyGatewayFilterFactory(codecConfigurer.getReaders());}@Beanpublic DedupeResponseHeaderGatewayFilterFactory dedupeResponseHeaderGatewayFilterFactory() { return new DedupeResponseHeaderGatewayFilterFactory();}@Beanpublic ModifyResponseBodyGatewayFilterFactory modifyResponseBodyGatewayFilterFactory(ServerCodecConfigurer codecConfigurer, Set<MessageBodyDecoder> bodyDecoders, Set<MessageBodyEncoder> bodyEncoders) { return new ModifyResponseBodyGatewayFilterFactory(codecConfigurer.getReaders(), bodyDecoders, bodyEncoders);}

確實需要這個bean

spring cloud gateway server項目是一個spring boot項目,在啟動的時候會去加載它的配置,其中有一個叫做GatewayClassPathWarningAutoConfiguration的配置類 代碼入下

@Configuration( proxyBeanMethods = false)//在 GatewayAutoConfiguration 執行執行 @AutoConfigureBefore({GatewayAutoConfiguration.class})public class GatewayClassPathWarningAutoConfiguration { private static final Log log = LogFactory.getLog(GatewayClassPathWarningAutoConfiguration.class); private static final String BORDER = 'nn**********************************************************nn'; public GatewayClassPathWarningAutoConfiguration() { } @Configuration(proxyBeanMethods = false ) @ConditionalOnMissingClass({'org.springframework.web.reactive.DispatcherHandler'}) protected static class WebfluxMissingFromClasspathConfiguration {public WebfluxMissingFromClasspathConfiguration() { GatewayClassPathWarningAutoConfiguration.log.warn('nn**********************************************************nnSpring Webflux is missing from the classpath, which is required for Spring Cloud Gateway at this time. Please add spring-boot-starter-webflux dependency.nn**********************************************************nn');} } @Configuration(proxyBeanMethods = false ) @ConditionalOnClass(name = {'org.springframework.web.servlet.DispatcherServlet'} ) protected static class SpringMvcFoundOnClasspathConfiguration {public SpringMvcFoundOnClasspathConfiguration() { GatewayClassPathWarningAutoConfiguration.log.warn('nn**********************************************************nnSpring MVC found on classpath, which is incompatible with Spring Cloud Gateway at this time. Please remove spring-boot-starter-web dependency.nn**********************************************************nn');} }}

我們pom中依賴了spring-boot-starter-web 也就是存在

org.springframework.web.servlet.DispatcherServlet

此時這個 與Spring Cloud Gateway不兼容

spring cloud gateway是基于webflux的,如果需要web支持的話需要導入spring-boot-starter-webflux取代spring-boot-start-web。

以上為個人經驗,希望能給大家一個參考,也希望大家多多支持好吧啦網。

標簽: Spring
主站蜘蛛池模板: 欧美三级在线观看视频 | 亚洲a在线播放 | 国产精品亚洲天堂 | 在线免费视频 | 99视频在线精品 | 欧美视频精品 | 亚洲精品乱无伦码 | 国产一区精品 | 精品久久久久久影院免费 | 免费一级片网站 | 欧美亚洲一级片 | 久久综合精品国产一区二区三区无 | 欧美精品久久天天躁 | 日韩一区二区三区视频 | 久久精品中文字幕不卡一二区 | 欧美最猛性xxxxx亚洲精品 | 久久精品国产91久久综合麻豆自制 | 91成人精品| 久久频这里精品99香蕉久网址 | 中文字幕在线观看一区二区 | 精品午夜寂寞黄网站在线 | 日韩一级性生活片 | 女人18毛片a级毛片 女人aaaaa片一级一毛片 | 欧美一级毛片一免费 | 怡红院免费va男人的天堂 | 一级毛片免费不卡在线视频 | 亚州中文字幕 | 国产午夜在线观看视频播放 | 日本久久久久 | 黄色大片三级 | 欧美日韩大片 | 国产三级免费观看 | 国产精品免费一区二区三区 | 在线观看视频中文字幕 | 国产禁女女网站免费看 | 成人福利网站含羞草 | 久草视屏 | 毛片免费观看视频 | 国产精品深爱在线 | 午夜嘿咻 | 无圣光福利视频 |