Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Caused by: java.lang.ClassNotFoundException: springfox.documentation.common.ClassPresentInClassPathCondition

I am trying to add Swagger to my project https://www.baeldung.com/swagger-2-documentation-for-spring-rest-api

I got 4.3 paragraph in the tutorial above and when I run my application, I got some errors.

This I added to my 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>

Also, I added config class :

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

And when I run my project, I got :

STACKTRACE1 STACKTRACE2

like image 426
Jack Avatar asked Nov 15 '25 19:11

Jack


1 Answers

I removed the following dependency from pom.xml

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

For me it worked

like image 92
Vidhya Natarajan Avatar answered Nov 18 '25 08:11

Vidhya Natarajan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!