解决SpringCloud gateway网关配置MVC拦截器报错问题
SpringCloud gateway网关配置MVC拦截器报错
报错问题
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.hmall.gateway.GatewayApplication]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/web/servlet/config/annotation/WebMvcConfigurer.class] cannot be opened because it does not exist

在spring.factories配置自动装配配置类

问题原因
因为网关没有引入SpringMVC,直接不会成效,会报错,写这个注解,有SpringMVC时候才生效
解决方案
在MVC配置类加上“@ConditionalOnClass(DispatcherServlet.class)”主页,表示使用mvc才加载这个配置
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
SpringBoot+Redis防止恶意刷新与暴力请求接口的实现
这篇文章主要为大家介绍了如何利用springboot和Redis来实现防止恶意刷新与暴力请求接口,文中的示例代码讲解详细,需要的可以参考一下2022-06-06
Spring RestTemplate简化HTTP通信实现功能探究
这篇文章主要为大家介绍了Spring框架中的RestTemplate,如果你是个Java程序员,那么你肯定知道Spring框架的重要性,在Spring的众多工具中,RestTemplate是用来简化HTTP通信的一个强大工具2024-01-01
Spring Boot 中的 @HystrixCommand 注解原理及使用方法
通过使用 @HystrixCommand 注解,我们可以轻松地实现对方法的隔离和监控,从而提高系统的可靠性和稳定性,本文介绍了Spring Boot 中的@HystrixCommand注解是什么,其原理以及如何使用,感兴趣的朋友跟随小编一起看看吧2023-07-07


最新评论