【问题标题】:No qualifying bean of type [org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping]没有 [org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping] 类型的限定 bean
【发布时间】:2019-03-11 10:16:41
【问题描述】:

我有一个配置了 swagger 的 Spring Boot 应用程序。我在运行黄瓜测试时遇到错误。以下是配置:

@Configuration
@EnableSwagger2
@EnableWebMvc
public class SwaggerConfig {  
}

@Category(IntegrationTest.class)
@RunWith(Cucumber.class)
@ContextConfiguration("classpath:cucumber-spring-beans.xml")
@CucumberOptions(snippets = SnippetType.CAMELCASE, strict = true, monochrome = true, tags = {"~@ManualTest", "~@SlowTest", "~@IgnoreTest", "~@AdHoc", "@IntegrationTest"}, 
features = {CucumberRunnerUtil.CukeFormat.FEATURE_FILE_LOCATION},
plugin = {"pretty", CucumberRunnerUtil.CukeFormat.CD_HTML_REPORT_INTEGRATION, 
        CucumberRunnerUtil.CukeFormat.CD_JSON_RESULTS_INTEGRATION + "integration-test-reports.json",
        CucumberRunnerUtil.CukeFormat.CD_JUNIT_XML_REPORT_INTEGRATION + "integration-test-reports.xml"})
public class RunIntegrationCukeTest {



}

黄瓜-spring-beans.xml:

<context:component-scan base-package="org.springframework.samples.mvc" />
<context:annotation-config/>

    <context:annotation-config/>
    <mvc:annotation-driven/>

    <context:component-scan base-package="com...." >
        <context:exclude-filter type="assignable" expression="com...."/>
    </context:component-scan>

    <context:component-scan base-package="com...." >

    </context:component-scan>

【问题讨论】:

标签: spring cucumber swagger


【解决方案1】:

从 cucumber-spring-beans.xml 中排除与 swagger 相关的 Java 配置类就成功了:

<context:component-scan base-package="...webservice.resource" >
        <context:exclude-filter type="assignable" expression="...webservice.resource.Application"/>
        <context:exclude-filter type="assignable" expression="...webservice.resource.SwaggerConfig"/>
        <context:exclude-filter type="assignable" expression="...webservice.resource.JerseyConfig"/>
        <context:exclude-filter type="assignable" expression="...webservice.resource.CombinedResourceProvider"/>    
    </context:component-scan>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-25
    • 2015-12-24
    • 2017-08-23
    • 1970-01-01
    • 2016-06-28
    相关资源
    最近更新 更多