Apache-Karate依赖关系导致Springboot 2.1.1 WebMVC控制器测试出错

时间:2019-05-09 12:23:51

标签: spring-boot karate

无论出于何种原因,我怀疑apache-karate引入了httpclient,因此每当我将apache-karate依赖项添加到我的POM时,都会破坏Spring WebMVC Controller测试。

我得到以下堆栈跟踪信息(我已经在其中搜索过):

  

创建名称为'requestMappingHandlerAdapter

的bean时出错
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerAdapter' defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcValidator' defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.valueextraction.ValueExtractorManager

我的WebConfiguration的一个片段是这样的:

@Configuration
@EnableWebMvc
public class WebConfiguration implements WebMvcConfigurer {

所以我知道这不是应用程序的配置方式。我的两个空手道依赖项的范围为test

由于对我来说这似乎是一个依赖问题,是否有其他人有玩弄这些依赖关系的经验,以便获得测试控制器工作的WebMvcTest类?

1 个答案:

答案 0 :(得分:0)

是的,理想情况下,您应该通过在exclusion上进行一些pom.xml黑客攻击来解决此问题。

实际上,您可以尝试将karate-apachekarate-jersey交换-我们拥有此选项的原因是为了解决这种确切的依赖冲突,这在文档中已提到。

如果您仍然遇到问题,请按照以下步骤进行操作,我们可以看看:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue