Skip to content

Latest commit

 

History

History
65 lines (48 loc) · 2.36 KB

README.adoc

File metadata and controls

65 lines (48 loc) · 2.36 KB

JaFu documentation

JaFu DSL for Spring Boot

JaFu (for Java and Functional) is an alternative way of configuring explicitly your Spring Boot application, different from regular auto-configuration, using a Java DSL. It is based on Spring Boot infrastructure, but used via functional bean definitions instead of JavaConfig.

API reference

An overview of JaFu DSL is provided below with the related API documentation. Be aware that a few static imports will be needed.

Getting started

  • Go to start.spring.io

  • Select the latest Spring Boot 2.6.x version

  • Add the Spring milestone repository https://repo.spring.io/milestone

  • Select the "Web" starter

  • Add the org.springframework.fu:spring-fu-jafu:0.5.1 dependency

  • Modify the generated DemoApplication.java file as following:

package com.sample;

import org.springframework.fu.jafu.JafuApplication;

import static org.springframework.fu.jafu.Jafu.webApplication;
import static org.springframework.fu.jafu.webmvc.WebMvcServerDsl.webMvc;

public class Application {

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

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

See also sample projects here.

Differences with regular Boot applications

  • Spring optimizations for native applications are enabled by default

  • XML support is disabled by default

  • SpEL support is disabled by default

  • Devtools automatic restart does not work yet so just restart your applications (very fast with JaFu)