The attempt was made from the following location: com.ruoyi.framework.config.ResourcesConfig.corsFilter(ResourcesConfig.java:57)

报错信息:

8:42:12.529 [restartedMain] ERROR o.s.b.w.e.t.TomcatStarter - [onStartup,61] - Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'corsFilter' defined in class path resource [com/ruoyi/framework/config/ResourcesConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.filter.CorsFilter]: Factory method 'corsFilter' threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.web.cors.CorsConfiguration.addAllowedOriginPattern(Ljava/lang/String;)V
18:42:12.597 [restartedMain] ERROR o.s.b.d.LoggingFailureAnalysisReporter - [report,40] - 

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    com.ruoyi.framework.config.ResourcesConfig.corsFilter(ResourcesConfig.java:57)

The following method did not exist:

    org.springframework.web.cors.CorsConfiguration.addAllowedOriginPattern(Ljava/lang/String;)V

The method's class, org.springframework.web.cors.CorsConfiguration, is available from the following locations:

    jar:file:/D:/z_GreenTools/repository/org/springframework/spring-web/5.2.12.RELEASE/spring-web-5.2.12.RELEASE.jar!/org/springframework/web/cors/CorsConfiguration.class

It was loaded from the following location:

    file:/D:/z_GreenTools/repository/org/springframework/spring-web/5.2.12.RELEASE/spring-web-5.2.12.RELEASE.jar

解决方法:

  • 找到如图路径:修改方法:config.addAllowedOriginPattern("*");

  • 修改为:config.addAllowedOrigin("*");

posted @ 2022-04-19 19:09  北极的大企鹅  阅读(781)  评论(0编辑  收藏  举报
阅读 - 79万