色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

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

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

瀏覽:2日期: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
主站蜘蛛池模板: 国产精品青草久久 | 亚洲欧美日韩国产精品久久 | 国产精品外围在线观看 | 久草在线视频看看 | 久草视频福利在线 | 中文字幕亚洲欧美日韩不卡 | 久久精品国产欧美日韩亚洲 | 久久久一本 | 日韩欧美毛片免费观看视频 | 九九精品激情在线视频 | 理论片中文字幕 | 久久久久久久久免费影院 | 欧美一级一一特黄 | 成人软件网18免费视频 | 最新久久免费视频 | 久夜色精品国产一区二区三区 | 国产三级毛片视频 | 在线观看免费av网站 | 波多野在线播放 | 国产欧美日韩精品一区二 | 日韩经典欧美精品一区 | 99九九视频| 免费一级α片在线观看 | 男女猛烈无遮掩免费视频 | 视频网18免费 | 日韩高清一级毛片 | 美国毛片网 | 久久精品综合免费观看 | 一本伊大人香蕉高清在线观看 | 国产乱码精品一区二区三区中 | 久久国产成人福利播放 | 久久久精品免费观看 | 色综合亚洲七七久久桃花影院 | 色综合久久88色综合天天提莫 | 在线播放第一页 | 亚洲午夜精品一级在线 | 国产欧美日韩在线观看一区二区三区 | 奇米888四色在线精品 | 国产肥老妇视频一 | 精品精品国产高清a毛片 | 手机看片欧美 |