This guide provides step-by-step instructions for modifying an existing Maven pom.xml
to add Ebean ORM with PostgreSQL support. Follow every step in order. This is Step 1 of 2.
- An existing Maven project (
pom.xmlalready exists) - Java 11 or higher
- The project does not yet include any Ebean dependencies
Open the module's pom.xml (the one that will use Ebean directly, i.e. the module
containing the database configuration and entity classes).
Inside the <properties> block, add the ebean.version property if it does not
already exist:
<properties>
<!-- add this line; use latest stable from https://github.com/ebean-orm/ebean/releases -->
<ebean.version>17.2.0</ebean.version>
</properties>If the project has a parent POM that already defines
ebean.version, skip this step.
Inside the <dependencies> block, add the PostgreSQL JDBC driver:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.8</version>
</dependency>Check Maven Central for the latest version. If the parent POM manages the PostgreSQL version, omit the
<version>tag.
Inside the <dependencies> block, add the Ebean Postgres platform dependency:
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-postgres</artifactId>
<version>${ebean.version}</version>
</dependency>This single artifact pulls in the Ebean core, the datasource connection pool
(ebean-datasource), and all Postgres-specific support.
ebean-test configures Ebean for tests and enables automatic Docker container management
for Postgres test instances:
<!-- test dependencies -->
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>${ebean.version}</version>
<scope>test</scope>
</dependency>Ebean requires bytecode enhancement to provide dirty-checking and lazy-loading.
The ebean-maven-plugin performs this enhancement at build time.
Inside the <build><plugins> block, add:
<plugin> <!-- perform ebean enhancement -->
<groupId>io.ebean</groupId>
<artifactId>ebean-maven-plugin</artifactId>
<version>${ebean.version}</version>
<extensions>true</extensions>
</plugin>The querybean-generator annotation processor generates type-safe query bean classes
at compile time. It must be registered as an annotationProcessorPath inside
maven-compiler-plugin.
Add the full plugin entry to <build><plugins>:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.15.0</version>
<configuration>
<annotationProcessorPaths>
<path> <!-- generate ebean query beans -->
<groupId>io.ebean</groupId>
<artifactId>querybean-generator</artifactId>
<version>${ebean.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>Locate the existing <annotationProcessorPaths> block inside the existing
maven-compiler-plugin entry and add the new <path> inside it. Do not add a
second <configuration> block or a second <annotationProcessorPaths> block.
Example — if the existing block already has a path for, say, avaje-nima-generator:
<annotationProcessorPaths>
<path>
<groupId>io.avaje</groupId>
<artifactId>avaje-nima-generator</artifactId>
<version>${avaje-nima.version}</version>
</path>
<!-- ADD the new path here, inside the existing block -->
<path>
<groupId>io.ebean</groupId>
<artifactId>querybean-generator</artifactId>
<version>${ebean.version}</version>
</path>
</annotationProcessorPaths>Run the following to confirm the POM is valid and the project compiles:
mvn compile -pl <your-module-name>Expected result: BUILD SUCCESS with no errors from Ebean or the annotation processor.
Proceed to Step 2: Configure the Datasource and Ebean Database bean
(add-ebean-postgres-database-config.md).