Python 官方文档:入门教程 => 点击学习
话不多说,直接上图 接口返回内容,浏览器显示pdf文档。但是输入接口地址以后一直提示这个 核对接口路径也是正确的,并且没有报错提示,后面发现是网关没有配置放行路径,于是进行了补充
接口返回内容,浏览器显示pdf文档。但是输入接口地址以后一直提示这个
核对接口路径也是正确的,并且没有报错提示,后面发现是网关没有配置放行路径,于是进行了补充
所以 以后对于前端请求统一由网关进行配置处理的,一定要对于静态资源合理配置,或者对于放行接口要统一补充进来(最后统一一下下接口前缀名称,这样就只需要写一个了)
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 这个类
@Bean
public ModifyRequestBodyGatewayFilterFactory modifyRequestBodyGatewayFilterFactory(ServerCodecConfigurer codecConfigurer) {
return new ModifyRequestBodyGatewayFilterFactory(codecConfigurer.getReaders());
}
@Bean
public DedupeResponseHeaderGatewayFilterFactory dedupeResponseHeaderGatewayFilterFactory() {
return new DedupeResponseHeaderGatewayFilterFactory();
}
@Bean
public 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 = "\n\n**********************************************************\n\n";
public GatewayClassPathWarningAutoConfiguration() {
}
@Configuration(
proxyBeanMethods = false
)
@ConditionalOnMissinGClass({"org.springframework.web.Reactive.DispatcherHandler"})
protected static class WebfluxMissingFromClasspathConfiguration {
public WebfluxMissingFromClasspathConfiguration() {
GatewayClassPathWarningAutoConfiguration.log.warn("\n\n**********************************************************\n\nSpring Webflux is missing from the classpath, which is required for Spring Cloud Gateway at this time. Please add spring-boot-starter-webflux dependency.\n\n**********************************************************\n\n");
}
}
@Configuration(
proxyBeanMethods = false
)
@ConditionalOnClass(
name = {"org.springframework.web.servlet.DispatcherServlet"}
)
protected static class springMVCFoundOnClasspathConfiguration {
public SpringmvcFoundOnClasspathConfiguration() {
GatewayClassPathWarningAutoConfiguration.log.warn("\n\n**********************************************************\n\nSpring MVC found on classpath, which is incompatible with Spring Cloud Gateway at this time. Please remove spring-boot-starter-web dependency.\n\n**********************************************************\n\n");
}
}
}
我们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。
以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。
--结束END--
本文标题: 解决spring boot网关gateway导致的坑,无法下载文件问题
本文链接: https://lsjlt.com/news/130613.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0