【问题标题】:Error when trying to run test in springboot尝试在 Spring Boot 中运行测试时出错
【发布时间】:2022-01-19 20:29:30
【问题描述】:

我尝试运行一些测试,但不知何故 spring 感到困惑,我得到下面的错误,这似乎是 Spring 尝试实例化的一些 bean 之间的一些冲突。有人有什么想法吗?

***************************
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:

    org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration.resourceHandlerMapping(WebMvcAutoConfiguration.java:408)

The following method did not exist:

    org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration.resourceHandlerMapping(Lorg/springframework/web/util/UrlPathHelper;Lorg/springframework/util/PathMatcher;Lorg/springframework/web/accept/ContentNegotiationManager;Lorg/springframework/format/support/FormattingConversionService;Lorg/springframework/web/servlet/resource/ResourceUrlProvider;)Lorg/springframework/web/servlet/HandlerMapping;

The method's class, org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration, is available from the following locations:

    jar:file:/home/test/stuff/.m2/repository/org/springframework/spring-webmvc/5.3.13/spring-webmvc-5.3.13.jar!/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class

The class hierarchy was loaded from the following locations:

    org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: file:/home/test/stuff/.m2/repository/org/springframework/spring-webmvc/5.3.13/spring-webmvc-5.3.13.jar
    org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport: file:/home/test/stuff/.m2/repository/org/springframework/spring-webmvc/5.3.13/spring-webmvc-5.3.13.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration

2021-12-16 19:46:21.564 ERROR [cc-task-allocation-backend,,,] 5484 --- [           main] o.s.test.context.TestContextManager      : Caught exception while allowing TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener@5ef5c734] to prepare test instance [eu.europa.ec.cc.taskallocation.services.RuleServiceUniformDistTest@61d4171d]

java.lang.IllegalStateException: Failed to load ApplicationContext
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
    

【问题讨论】:

  • 您能否发布您的 pom 文件(或 build.gradle)并将其添加到您的问题中,它看起来像依赖管理问题。
  • 其实确实是依赖管理问题。谢谢!

标签: spring spring-boot spring-mvc


【解决方案1】:

依赖管理问题,因为 org.junit.jupiter 依赖被启动器覆盖。

【讨论】:

  • 你能提供解决方案吗?
猜你喜欢
  • 2021-10-08
  • 1970-01-01
  • 2019-02-17
  • 1970-01-01
  • 1970-01-01
  • 2019-11-18
  • 1970-01-01
  • 1970-01-01
  • 2011-12-03
相关资源
最近更新 更多