2020-06-01

Spring application With JaFu configuration

Spring boot application With JaFu configuration:

Spring Fu is an incubator for Spring Boot programmatic configuration using DSLs in order to configure it explicitly with code in a declarative way, achieving great discoverability thanks to auto-complete.

public class Application {

public static JafuApplication app = webApplication(a -> a.beans(b -> b
.bean(SampleHandler.class)
.bean(SampleService.class))
.enable(webMvc(w -> w
.port(w.profiles().contains("test") ? 8181 : 8080)
.router(router -> {
SampleHandler handler = w.ref(SampleHandler.class);
router
.GET("/", handler::hello)
.GET("/api", handler::json);
}).converters(c -> c
.string()
.jackson(j -> j.indentOutput(true))))));

public static void main (String[] args) {
app.run(args);
}
}

No comments:

Post a Comment