This is a template project, based on my experience and my opinion, that shows how to integrate Vaadin and jOOQ and how to test it with Karibu Testing and Playwright.
It uses Testcontainers for generating the jOOQ classes and integration testing and Flyway for the database migrations.
This project can be used as a starting point to create your own Vaadin application with jOOQ. It contains all the necessary configurations and some examples to get you started.
Before running the application, the jOOQ metamodel has to be generated using the Maven plugin:
./mvnw compile
Then you can run the application with a database started by Testcontainers from your IDE using the TestVjApplication
.
Important: This class uses the Spring Boot Testcontainers support, introduced with Spring Boot 3.1. Thus, Docker or Testcontainers Cloud must be running on your local computer.
There are two base classes:
KaribuTest
can be used for fast browser-less testing, aka UI unit test. Karibu sets up a Vaadin mock environment.PlaywrightIT
configures Playwright for E2E tests. This class uses SpringBootTest at a random port.
The Playwright test uses Mopo, which simplifies the testing of Vaadin applications with Playwright.
To create a production build, call mvnw clean package -Pproduction
(Windows),
or ./mvnw clean package -Pproduction
(Mac & Linux).
This will build a JAR file with all the dependencies and front-end resources, ready to be deployed. You can find
the file in the target
folder after the build completes.
Once the JAR file is built, you can run it using java -jar target/vaadin-jooq-template-<version>.jar
layout/MainLayout.java
insrc/main/java
contains the navigation setup using App Layout.views
package insrc/main/java
contains the server-side Java views of your application.themes
folder infrontend/
contains the custom CSS styles.
The example uses JWT authentication for a better developer experience (for example, you don't have to re-log in during development). Read more in the blog of Matti Tahvonen.
- Check out the Vaadin Developer Portal.
- Read the documentation at vaadin.com/docs.
- Create new projects at start.vaadin.com.
- Find a collection of solutions to common use cases at cookbook.vaadin.com.
- Find add-ons at vaadin.com/directory.
- Read the documentation at jooq.org/learn.
- Browse the Blog.
- Explore the Spring Boot project page.
- Go to the Testcontainers website.
- Check out the GitHub project.
- Read the documentation.