小编Jac*_*ack的帖子

引起原因:java.lang.ClassNotFoundException:springfox.documentation.common.ClassPresentInClassPathCondition

我正在尝试将 Swagger 添加到我的项目https://www.baeldung.com/swagger-2-documentation-for-spring-rest-api

我在上面的教程中得到了 4.3 段落,当我运行我的应用程序时,我遇到了一些错误。

我将其添加到我的pom.xml

    <dependency>
  <groupId>io.springfox</groupId>
  <artifactId>springfox-swagger2</artifactId>
  <version>2.9.2</version>
</dependency>

<dependency>
  <groupId>io.springfox</groupId>
  <artifactId>springfox-boot-starter</artifactId>
  <version>3.0.0</version>
</dependency>

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>2.4.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

另外,我添加了配置类:

@Configuration
public class SwaggerConfig {
@Bean
public Docket api() {
    return new Docket(DocumentationType.SWAGGER_2)
            .select()
            .apis(RequestHandlerSelectors.any())
            .paths(PathSelectors.any())
            .build();
}
}
Run Code Online (Sandbox Code Playgroud)

当我运行我的项目时,我得到:

堆栈跟踪1 堆栈跟踪2

java swagger spring-boot springfox

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

标签 统计

java ×1

spring-boot ×1

springfox ×1

swagger ×1