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才加载这个配置
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论