Last active
February 22, 2019 20:47
-
-
Save paul58914080/d8c9d4263438eb06545ffa8eedd2aac1 to your computer and use it in GitHub Desktop.
FF4j spring boot starter workaround for spring boot 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration; | |
/** | |
* Created by Paul | |
* | |
* @author <a href="mailto:paul58914080@gmail.com">Paul Williams</a> | |
*/ | |
@SpringBootApplication(exclude = ThymeleafAutoConfiguration.class) | |
public class Application { | |
public static void main(String[] args) { | |
SpringApplication.run(Application.class, args); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.ff4j.FF4j; | |
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.ComponentScan; | |
import org.springframework.context.annotation.Configuration; | |
/** | |
* Created by Paul | |
* | |
* @author <a href="mailto:paul58914080@gmail.com">Paul Williams</a> | |
*/ | |
@Configuration | |
@ComponentScan(value = {"org.ff4j.spring.boot.web.api", "org.ff4j.services", "org.ff4j.aop", "org.ff4j.spring"}) | |
public class FF4JConfiguration { | |
@Bean | |
@ConditionalOnMissingBean | |
public FF4j getFF4j() { | |
return new FF4j(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.ff4j.FF4j; | |
import org.ff4j.web.FF4jDispatcherServlet; | |
import org.ff4j.web.embedded.ConsoleServlet; | |
import org.springframework.boot.autoconfigure.AutoConfigureAfter; | |
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | |
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | |
import org.springframework.boot.web.servlet.ServletRegistrationBean; | |
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
@Configuration | |
@ConditionalOnClass({ConsoleServlet.class, FF4jDispatcherServlet.class}) | |
@AutoConfigureAfter(FF4JConfiguration.class) | |
public class FF4JWebConfiguration extends SpringBootServletInitializer { | |
@Bean | |
public ServletRegistrationBean servletRegistrationBean(ConsoleServlet ff4jConsoleServlet) { | |
return new ServletRegistrationBean(ff4jConsoleServlet, "/ff4j-console"); | |
} | |
@Bean | |
@ConditionalOnMissingBean | |
public ConsoleServlet getFF4jServlet(FF4j ff4j) { | |
ConsoleServlet ff4jConsoleServlet = new ConsoleServlet(); | |
ff4jConsoleServlet.setFf4j(ff4j); | |
return ff4jConsoleServlet; | |
} | |
@Bean | |
public ServletRegistrationBean ff4jDispatcherServletRegistrationBean(FF4jDispatcherServlet ff4jDispatcherServlet) { | |
return new ServletRegistrationBean(ff4jDispatcherServlet, "/ff4j-web-console/*"); | |
} | |
@Bean | |
@ConditionalOnMissingBean | |
public FF4jDispatcherServlet getFF4jDispatcherServlet(FF4j ff4j) { | |
FF4jDispatcherServlet ff4jConsoleServlet = new FF4jDispatcherServlet(); | |
ff4jConsoleServlet.setFf4j(ff4j); | |
return ff4jConsoleServlet; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns="http://maven.apache.org/POM/4.0.0" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>org.ff4j</groupId> | |
<artifactId>ff4j-spring-boot-sample</artifactId> | |
<packaging>jar</packaging> | |
<version>AVENGERS-SNAPSHOT</version> | |
<parent> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-parent</artifactId> | |
<version>2.1.3.RELEASE</version> | |
</parent> | |
<properties> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
<java.version>1.8</java.version> | |
<kotlin.version>1.3.0</kotlin.version> | |
<start-class>org.ff4j.sample.Application</start-class> | |
</properties> | |
<dependencies> | |
<dependency> | |
<groupId>org.ff4j</groupId> | |
<artifactId>ff4j-spring-boot-starter</artifactId> | |
<version>AVENGERS-SNAPSHOT</version> | |
</dependency> | |
<dependency> | |
<groupId>org.ff4j</groupId> | |
<artifactId>ff4j-web</artifactId> | |
<version>1.7.3</version> | |
</dependency> | |
<dependency> | |
<groupId>org.thymeleaf</groupId> | |
<artifactId>thymeleaf</artifactId> | |
<version>2.1.4.RELEASE</version> | |
</dependency> | |
</dependencies> | |
<build> | |
<resources> | |
<resource> | |
<directory>src/main/resources</directory> | |
</resource> | |
</resources> | |
<plugins> | |
<plugin> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-maven-plugin</artifactId> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<executions> | |
<execution> | |
<id>compile</id> | |
<phase>compile</phase> | |
<goals> | |
<goal>compile</goal> | |
</goals> | |
</execution> | |
<execution> | |
<id>testCompile</id> | |
<phase>test-compile</phase> | |
<goals> | |
<goal>testCompile</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment