成人视屏在线观看-国产99精品-国产精品1区2区-欧美一级在线观看-国产一区二区日韩-色九九九

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

解決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
主站蜘蛛池模板: 波多野在线播放 | 日韩视频中文字幕 | 国产成人欧美一区二区三区的 | 久久99国产亚洲高清观看首页 | 男人的天堂久久精品激情 | 香港三级日本三级三级人妇 | 日韩欧美一区二区三区不卡视频 | 亚洲第99页| 精品国产福利 | 久久久久久a亚洲欧洲aⅴ | 亚洲一区二区三 | 免费人成网站在线播放 | 国产91在线 | 亚洲 | 男人一进一出桶女人视频 | 黄色大片三级 | 国产一区精品在线观看 | 69欧美 | 久久亚洲国产精品五月天 | 亚洲精品国产第一区二区三区 | 亚洲综合视频 | 亚洲国产精品久久精品成人 | 国产99视频精品草莓免视看 | 国产黄色网 | 99久久精品国产一区二区三区 | 香港三级日本三级妇人三级 | 99亚洲精品| 色妇女影院| 国产精品欧美一区二区在线看 | 成人a视频 | 在线观看一级毛片免费 | 久草在线新首页 | 99国产精品免费视频观看 | 国产成人精品男人免费 | 国美女福利视频午夜精品 | 欧美成人免费香蕉 | 欧美精品久久久亚洲 | 国产精品欧美亚洲日本综合 | 欧美俄罗斯一级毛片 | 国产精品一国产精品免费 | 日本国产在线 | 岛国午夜精品视频在线观看 |