相关疑难解决方法(0)

Spring Boot + Springbox招摇错误

我有一个春季启动项目希望通过springbox与swagger集成.

我的弹簧启动应用程序运行良好.

但是在我添加springbox之后,它无法通过单元测试.

以下是我在项目中添加的详细信息.

对于pom.xml,补充说

  <!--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>
Run Code Online (Sandbox Code Playgroud)

然后使用swagger配置类

@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();
}

}
Run Code Online (Sandbox Code Playgroud)

运行时我得到的错误mvn clean package

  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 …
Run Code Online (Sandbox Code Playgroud)

java spring swagger spring-boot

14
推荐指数
2
解决办法
2万
查看次数

标签 统计

java ×1

spring ×1

spring-boot ×1

swagger ×1