java

关注公众号 jb51net

关闭
首页 > 软件编程 > java > SpringCloud gateway网关配置MVC拦截器报错

解决SpringCloud gateway网关配置MVC拦截器报错问题

作者:一枚小蜗牛H

这篇文章主要介绍了解决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才加载这个配置

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:
阅读全文