Skip to content

Micronaut

🎬 Mateu on Micronaut, drawn by the Redwood renderer — on YouTube

Start from any Micronaut application: create one at Micronaut Launch, with the mn CLI or from IntelliJ. One mateu-micronaut jar serves both supported lines:

MicronautJavaBuild
5.x (what Launch generates)25Maven 3.9.10 or later (Launch’s mvnw has it), or Gradle
4.10.x21 or laterMaven or Gradle

Micronaut 5’s own Maven rules need Maven 3.9.10: with 3.9.9 or earlier the build stops at maven-enforcer-plugin with ClassNotFoundException: …CheckSnakeYaml. Use the project’s ./mvnw or a newer Maven.

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-micronaut</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 (appended to the Micronaut ones):

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

The annotation processor (mateu-annotation-processor-micronaut) 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-micronaut")
implementation("io.mateu:mateu-vaadin")
annotationProcessor("io.mateu:mateu-annotation-processor-micronaut")

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).

Two settings matter for a Micronaut app that serves Mateu under concurrent load:

  • Ship a logback.xml. Without one, logback logs everything at DEBUG — Micronaut’s own bean resolution included — and every line takes the console appender’s lock. Put one at INFO in src/main/resources (the starters/micronaut project has it):

    <configuration>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder><pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern></encoder>
    </appender>
    <root level="info"><appender-ref ref="STDOUT"/></root>
    </configuration>
  • Know which threads run the handlers. On Java 21+ Micronaut’s blocking executor — where it dispatches Mateu’s action endpoints — runs on virtual threads. On JDK 21–23 a virtual thread that blocks while it holds, or waits for, a synchronized monitor pins its carrier thread; Micronaut’s bean context resolves beans inside synchronized sections, and with DEBUG logging those sections wait on logback’s lock. A burst of concurrent requests on a cold server can then pin every carrier and the server stops answering (a thread dump shows every ForkJoinPool-1-worker “Carrying virtual thread” parked in OutputStreamAppender.writeBytes). Mateu’s own one-time loads no longer hold a monitor, and INFO logging removes the trigger. The adapter logs one WARN at startup when it runs on JDK 21–23 with virtual threads on. If you must stay on JDK 21 with verbose logging or other pinning libraries, either:

    • run on JDK 24 or later, where synchronized no longer pins (JEP 491) — the recommended fix; or

    • give the blocking executor platform threads:

      micronaut.executors.blocking.virtual=false

Nothing special is required. Your application class stays as usual:

public class Application {
public static void main(String[] args) {
Micronaut.run(Application.class, args);
}
}

Mateu’s beans, bean introspections and JSON serialization ship inside the mateu-micronaut jar and are discovered from the classpath, and the adapter serves the renderer’s assets (/assets/…, /_redwood/…) straight from the renderer jar, so no annotations nor extra configuration properties are needed. (Up to 3.0.1 the app had to map them with micronaut.router.static-resources.<name>.paths=classpath:static; that mapping still works, and can go.)

Just annotate your class with @UI:

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

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

The @UI classes may also live in a framework-agnostic module (only mateu-uidl, compiled with mateu-annotation-processor-indexer), with the Micronaut app holding nothing but its Application class. Put that UI module on the app’s annotationProcessorPaths too (besides the regular dependency), next to Micronaut’s own processors and mateu-annotation-processor-micronaut: Mateu reads the module’s index there and generates the controllers early enough for Micronaut’s processor to turn them into beans in the same compilation. (Up to 3.0-beta they were generated in javac’s last round, which no processor sees, and such an app answered 404 on every mount.)

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/micronaut project; CI compiles and boots it on every change.