Spring Boot + Springbox swagger error Spring Boot + Springbox swagger error spring spring

Spring Boot + Springbox swagger error


Been looking into this problem for the while morning without luck, then posted this question. Just after posted the question, I found out the solution for this..... (I blame on the not-so-good morning coffee)

Simply remove the @Configuration annotation in the swagger configuration class.

Here is the link I refer to

https://github.com/springfox/springfox/issues/462


I was facing the exact same issue. Here is the solution.

Add this to application-test.properties (Create one if not already present)

spring.profiles.active=test

Annotate the test (if not already present)

@TestPropertySource(locations = "classpath:application-test.properties")

Create a new Swagger Configuration class and annotate it as following:

@Configuration@EnableSwagger2@Profile("!test")public class SwaggerConfig {    @Bean    public Docket api() {        .........    }}

This will make sure that swagger config is not loaded for test at all.


Add a Profile annotation as below

@Profile("dev")@Configuration@EnableSwagger2public class SwaggerConfig {

so that swagger is not loaded this class not invoked during the compile/build/test life cycleand Add the below property to application-test.properties (Create one if not already present under src/test/resources folder)spring.profiles.active=testresolved the issue for me.