Maven pom.xml имел исключить Springdoc FF4J из-за конфликтов с моим собственным
Код: Выделить всё
org.springframework.boot
spring-boot-starter-thymeleaf
3.2.5
org.ff4j
ff4j-spring-boot-starter
1.9
org.springdoc
springdoc-openapi-ui
org.ff4j
ff4j-web
2.0.0
Код: Выделить всё
package feature_toggle;
import org.ff4j.FF4j;
import org.ff4j.core.Feature;
import org.ff4j.strategy.time.ReleaseDateFlipStrategy;
import org.ff4j.web.FF4jDispatcherServlet;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class Ff4jConfig {
public static final String HELLO_EXAMPLE_FEATURE = "HELLO_EXAMPLE_FEATURE";
@Bean
public FF4j ff4j(){
FF4j ff4j = new FF4j();
var feature = new Feature(HELLO_EXAMPLE_FEATURE);
feature.setEnable(false);
feature.setFlippingStrategy(new ReleaseDateFlipStrategy("2024-06-20-20:00"));
ff4j.createFeature(feature);
return ff4j;
}
@Bean
@ConditionalOnMissingBean
public FF4jDispatcherServlet ff4jDispatcherServlet(FF4j ff4j){
FF4jDispatcherServlet ff4jDispatcherServlet = new FF4jDispatcherServlet();
ff4jDispatcherServlet.setFf4j(ff4j);
return ff4jDispatcherServlet;
}
@Bean
public ServletRegistrationBean servletRegistrationBean(FF4jDispatcherServlet ff4jDispatcherServlet){
return new ServletRegistrationBean(ff4jDispatcherServlet, "/ff4j-web-console/*");
}
}
Код: Выделить всё
@Service
public class FF4JService {
@Autowired
private FF4j ff4j;
@Bean
public CommandLineRunner commandLineRunner(){
return args -> {
while(true){
if(ff4j.check(Ff4jConfig.HELLO_EXAMPLE_FEATURE)){
System.out.println("Hello World!");
} else {
System.out.println("Something went wrong!");
}
Thread.sleep(5000);
}
};
}
}

Подробнее здесь: https://stackoverflow.com/questions/784 ... the-featur