Skip to content

Springboot Webflux

🎬 Mateu on Spring WebFlux — on YouTube

Obviously you need a valid spring boot project, with Reactive Web (Webflux) enabled. If you do not have it already, you should create it from IntelliJ or go to Spring Boot Initializr and create a new project with the Reactive Web dependency.

Import Mateu’s BOM once, so no Mateu artifact needs a version of its own:

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.mateu</groupId>
<artifactId>mateu-bom</artifactId>
<version>3.0.5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Then the runtime dependencies:

<dependency>
<groupId>io.mateu</groupId>
<artifactId>mateu-webflux</artifactId>
</dependency>
<!-- serves the built-in frontend; choose one: mateu-vaadin (Vaadin), mateu-redwood (Oracle Redwood / Visual Builder) -->
<dependency>
<groupId>io.mateu</groupId>
<artifactId>mateu-vaadin</artifactId>
</dependency>

And the annotation processor, on the processor path:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<!-- list Lombok, MapStruct… here too if you use them -->
<path>
<groupId>io.mateu</groupId>
<artifactId>mateu-annotation-processor-webflux</artifactId>
<version>3.0.5</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>

The annotation processor (mateu-annotation-processor-webflux) goes on the annotation processor path only — never as a regular <dependency>: it is a compile-time code generator, and as a dependency it would ship its own libraries (FreeMarker, Guava) inside your application. Its jar declares itself to Gradle as an incremental (aggregating) processor.

Or, with Gradle:

implementation(platform("io.mateu:mateu-bom:3.0.5"))
annotationProcessor(platform("io.mateu:mateu-bom:3.0.5"))
implementation("io.mateu:mateu-webflux")
implementation("io.mateu:mateu-vaadin")
annotationProcessor("io.mateu:mateu-annotation-processor-webflux")

See Configuration properties for what you can tune — notably cross-origin access (off unless you list the origins) and the MCP endpoint (off unless enabled).

Nothing special is required. Just annotate your class with @UI:

package com.example.demo;
import io.mateu.uidl.annotations.UI;
@UI("")
public class HelloWorld {
}

When you run you spring boot application, you will find your ui at http://localhost:8080 (for the code above) as expected:

An empty class renders an empty page. For a complete project on this runtime — a model, a store and a full CRUD, with this exact build setup — copy the starters/spring-webflux project; CI compiles and boots it on every change.

Your CrudStore, load() and action methods are ordinary synchronous code (JDBC, files, a REST client): Mateu runs every action off the Netty event loop, on Reactor’s boundedElastic scheduler, so a slow store never stalls the loop that serves the other requests and the static assets.

The controllers the annotation processor generates live next to your @UI classes. When those are not under your main class’s package (a separate UI module, say), name their package — or the mount answers 404:

@SpringBootApplication(scanBasePackages = {"com.example.myapp", "com.example.myui"})

or, without touching the main class, mateu.ui.modules=com.example.myui in application.properties. Do not scan io.mateu: Mateu’s own beans come with the adapter. See multi-module projects for the two-step annotation processing a UI module needs.

In case you are using a maven project and you are setting custom annotation processor paths (e.g. because you are using mapstruct) you must add the annotation processor from Mateu, in your pom.xml:

<build>
<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>
<version>3.13.0</version>
<configuration>
<source>21</source>
<target>21</target>
<annotationProcessorPaths>
<path> <!-- when using mapstruct -->
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
<path>
<groupId>io.mateu</groupId>
<artifactId>mateu-annotation-processor-webflux</artifactId>
<version>3.0.5</version>
</path>
<!-- other annotation processors -->
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>