解決SpringCloud gateway網(wǎng)關配置MVC攔截器報錯問題
SpringCloud gateway網(wǎng)關配置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配置自動裝配配置類
問題原因
因為網(wǎng)關沒有引入SpringMVC,直接不會成效,會報錯,寫這個注解,有SpringMVC時候才生效
解決方案
在MVC配置類加上“@ConditionalOnClass(DispatcherServlet.class)”主頁,表示使用mvc才加載這個配置
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
SpringBoot+Redis防止惡意刷新與暴力請求接口的實現(xiàn)
這篇文章主要為大家介紹了如何利用springboot和Redis來實現(xiàn)防止惡意刷新與暴力請求接口,文中的示例代碼講解詳細,需要的可以參考一下2022-06-06Spring Eureka 未授權(quán)訪問漏洞修復問題小結(jié)
項目組使用的 Spring Boot 比較老,是 1.5.4.RELEASE ,最近被檢測出 Spring Eureka 未授權(quán)訪問漏洞,這篇文章主要介紹了Spring Eureka 未授權(quán)訪問漏洞修復問題小結(jié),需要的朋友可以參考下2024-04-04Java ArrayList如何實現(xiàn)生成不重復隨機數(shù)
這篇文章主要介紹了Java ArrayList如何實現(xiàn)生成不重復隨機數(shù),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2020-09-09Spring RestTemplate簡化HTTP通信實現(xiàn)功能探究
這篇文章主要為大家介紹了Spring框架中的RestTemplate,如果你是個Java程序員,那么你肯定知道Spring框架的重要性,在Spring的眾多工具中,RestTemplate是用來簡化HTTP通信的一個強大工具2024-01-01Spring?Boot?中的?@HystrixCommand?注解原理及使用方法
通過使用 @HystrixCommand 注解,我們可以輕松地實現(xiàn)對方法的隔離和監(jiān)控,從而提高系統(tǒng)的可靠性和穩(wěn)定性,本文介紹了Spring Boot 中的@HystrixCommand注解是什么,其原理以及如何使用,感興趣的朋友跟隨小編一起看看吧2023-07-07