av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

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

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

瀏覽:20日期: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
主站蜘蛛池模板: 国产精品久久久久久久岛一牛影视 | 日本久久视频 | 久草热线| 亚洲精品v | 福利色导航 | av国产精品| 午夜精品导航 | 欧美一区二区三区四区视频 | 精品国产乱码一区二区三区 | 久久一区二区三区四区五区 | 黄色大片免费播放 | 日韩成人中文字幕 | 日韩av在线免费 | 美女一级毛片 | 国产高清精品一区二区三区 | 日韩精品成人 | 国产视频一区二区在线观看 | 久久亚洲一区 | 日韩国产欧美 | 成人免费一区二区三区牛牛 | 国产一级片精品 | 欧美日韩视频 | 国产精品不卡一区 | 91视频www.| 成人免费网站 | 91久久久久 | 国产精品国产三级国产aⅴ中文 | 在线视频成人 | 亚洲精品久久久一区二区三区 | 国产黄色网址在线观看 | 毛片免费在线 | 欧美视频成人 | 久久视频精品 | 日韩成人在线视频 | 亚洲视频在线看 | 日韩在线观看网站 | 国产福利在线播放麻豆 | 国产在线一区二区三区 | 国产目拍亚洲精品99久久精品 | 免费在线精品视频 | www.99热.com |