Spring Boot + Springbox swagger Fehler

Ich habe eine spring-boot-Projekt integrieren wollen, mit swagger via springbox.

Habe ich meine spring-boot-app und läuft alles gut.

Aber nachdem ich Hinzugefügt springbox, es kann nicht passieren unit-test.

Hier sind die details, die ich Hinzugefügt im Projekt.

Für pom.xml Hinzugefügt

  <!--Swagger io for API doc-->
  <dependency>
        <groupId>io.swagger</groupId>
        <artifactId>swagger-core</artifactId>
        <version>1.5.3</version>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.2.2</version>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.2.2</version>
    </dependency>

dann mit swagger config-Klasse

@Configuration
@EnableSwagger2
public class SwaggerConfig {

@Bean
public Docket booksApi() {
    return new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(apiInfo())
            .select()
            .apis(RequestHandlerSelectors.any())
            .paths(PathSelectors.regex("/.*"))
            .build();
}

private ApiInfo apiInfo() {
    return new ApiInfoBuilder()
            .title("blah")
            .description("blah.")
            .termsOfServiceUrl("http://www.blah.com.au")
            .contact("blah")
            .build();
}

}

Den Fehler bekomme ich beim ausführen mvn clean package ist

  org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webMvcRequestHandlerProvider' defined in URL [jar:file:/Users/jasonfeng/.m2/repository/io/springfox/springfox-spring-web/2.2.2/springfox-spring-web-2.2.2.jar!/springfox/documentation/spring/web/plugins/WebMvcRequestHandlerProvider.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [java.util.List]: : No qualifying bean of type [org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping] found for dependency [collection of org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping] found for dependency [collection of org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}

die version, die ich verwende, ist

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.2.5.RELEASE</version>
</parent>
Schreibe einen Kommentar