Spring boot FF4j ff4j-spring-boot-starter excluding swagger doc

964 Views Asked by At

I need in my spring boot application FF4j. I try

<dependency>
  <groupId>org.ff4j</groupId>
  <artifactId>ff4j-spring-boot-starter</artifactId>
  <version>1.8</version>
</dependency>

and in this case my application is broken because of swagger.

can I exclude org.ff4j.spring.boot.web.api.config.SwaggerConfig from my configuration?

I tried to manage it but cant reach final solution because of new different issues.

1

There are 1 best solutions below

0
On BEST ANSWER

In case you configure swagger in your application in usual case it will be failed because of different reasons. Possible next ones:

  • spring needs resolve which swagger bean should be used;
  • cg-lib conflict in case you used bean name api;
  • swagger conflict because two different Docket beans in same spring context;

    1. Firstly I tried to exclude ff4j-spring auto configuration configuring steps in similar way but excluding swagger for example. Application can't start ff4j without their swagger. That's confused a lot.

    2. Looking different solutions I tried follow some recommendations like but I'm getting different issue with missed class for my application. Missed class is in thymeleaf5. I can't use thymeleaf5 because of it uses same name interface but different arguments. Additional workarounds make my application failed because of hibernate.

Swagger solution is:

in your configuration inject swagger Docket from ff4j:

@Autowired
Docket api;

and rewrite api with your configuration in @PostConstruct block. This solution is not elegant, but provides fix for swagger configs.

@PostConstruct
public void reconfigureSwagger() {
  api....
}

P.S.

After swagger issue I've got more unresolved elements (but that's will be a different questions).

P.S.2.

FF4j library provides great UI and ideas and this is general reason why I do not avoid of its headache.