午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

解決spring boot網(wǎng)關(guān)gateway導(dǎo)致的坑,無(wú)法下載文件問(wèn)題

瀏覽:32日期:2023-07-02 08:06:23
話不多說(shuō),直接上圖

解決spring boot網(wǎng)關(guān)gateway導(dǎo)致的坑,無(wú)法下載文件問(wèn)題

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

解決spring boot網(wǎng)關(guān)gateway導(dǎo)致的坑,無(wú)法下載文件問(wèn)題

核對(duì)接口路徑也是正確的,并且沒(méi)有報(bào)錯(cuò)提示,后面發(fā)現(xiàn)是網(wǎng)關(guān)沒(méi)有配置放行路徑,于是進(jìn)行了補(bǔ)充

解決spring boot網(wǎng)關(guān)gateway導(dǎo)致的坑,無(wú)法下載文件問(wèn)題

所以 以后對(duì)于前端請(qǐng)求統(tǒng)一由網(wǎng)關(guān)進(jìn)行配置處理的,一定要對(duì)于靜態(tài)資源合理配置,或者對(duì)于放行接口要統(tǒng)一補(bǔ)充進(jìn)來(lái)(最后統(tǒng)一一下下接口前綴名稱(chēng),這樣就只需要寫(xiě)一個(gè)了)

下面我再說(shuō)一個(gè)坑:

spring cloud gateway啟動(dòng)報(bào)錯(cuò):org.springframework.cloud.gateway.config.GatewayAutoConfiguration

springcloud 啟動(dòng)一直報(bào)錯(cuò) 詳細(xì)錯(cuò)誤信息

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 移除

詳細(xì)分析

點(diǎn)進(jìn)去 GatewayAutoConfiguration 這個(gè)類(lèi)

@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);}

確實(shí)需要這個(gè)bean

spring cloud gateway server項(xiàng)目是一個(gè)spring boot項(xiàng)目,在啟動(dòng)的時(shí)候會(huì)去加載它的配置,其中有一個(gè)叫做GatewayClassPathWarningAutoConfiguration的配置類(lèi) 代碼入下

@Configuration( proxyBeanMethods = false)//在 GatewayAutoConfiguration 執(zhí)行執(zhí)行 @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中依賴(lài)了spring-boot-starter-web 也就是存在

org.springframework.web.servlet.DispatcherServlet

此時(shí)這個(gè) 與Spring Cloud Gateway不兼容

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

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Spring
主站蜘蛛池模板: 长河落日电视连续剧免费观看01 | 久久中文字 | 在线视频福利 | 欧美日韩高清一区二区三区 | 久久精品99国产精 | 激情国产一区 | 午夜999| 久久久久国产 | 天堂资源在线 | 久久99深爱久久99精品 | 日日爽日日操 | 国产成人三级在线播放 | 成年人在线视频免费观看 | 一级黄色在线观看 | 成人免费视频网站入口 | 久久99在线| 色爽网站| 91国视频| 欧美aaa级片 | 亚洲黄色视屏 | 日一区二区 | 亚洲精品在 | 丁香婷婷亚洲 | 天堂综合 | 北条麻妃青青久久 | 欧美一级大片免费看 | 男人的天堂av网站 | 天堂岛av| 五月婷婷一区二区 | 黄色工厂这里只有精品 | 久久久亚洲一区 | 寂寞午夜影院 | juliaann欧美二区三区 | 日本黄色一区 | 亚洲国产精品激情在线观看 | 亚洲在线免费观看视频 | 中文字幕第一页av | 亚洲欧美成人综合 | 亚洲一区无| 成人欧美一区二区三区在线观看 | 国产美女免费观看 |