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

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

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

瀏覽:13日期: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
主站蜘蛛池模板: 92精品国产自产在线观看 | 日本在线观看一级高清片 | a级毛片在线观看 | 久久精品国产99国产精品免费看 | 97精品国产福利一区二区三区 | 一级性片 | 老司机亚洲精品影院在线 | 久久久久久久久久久久久久久久久久 | 亚洲最大免费视频网 | 国产成人综合网在线播放 | 国产91精品一区 | 国内精品自产拍在线观看91 | 99国产国人青青视频在线观看 | 日韩免费专区 | 亚洲精品久久精品h成人 | 国产一级毛片国语版 | 久久免费99精品久久久久久 | 日韩欧美亚洲国产 | 久久精品操 | 亚州精品视频 | 美日韩一区二区三区 | 精品国产一区二区三区国产馆 | 在线黄| 久久亚洲精品tv | 国产一区二 | 欧美+日本+国产+在线观看 | 亚洲高清免费在线观看 | 国产精品久久久久久久久免费 | 欧美视频一区二区三区在线观看 | 天天激情站| 久久久久久久久免费影院 | 美女张开腿给人网站 | 狠久久| 一级毛片免费观看 | 中文字幕欧美在线观看 | 草草草在线观看 | 国产精品成人免费视频 | 成人亚洲国产 | 欧美高清亚洲欧美一区h | 欧美成人做爰网站 | 精品国产91久久久久久久a |