# Guide: Add Ebean ORM (PostgreSQL) to an Existing Maven Project — Step 1: POM Setup ## Purpose 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 3. --- ## Prerequisites - An existing Maven project (`pom.xml` already exists) - Java 11 or higher - The project does **not** yet include any Ebean dependencies --- ## Step 1 — Define the Ebean version property 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 `` block, add the `ebean.version` property if it does not already exist: ```xml 17.2.0 ``` > If the project has a parent POM that already defines `ebean.version`, skip this step. --- ## Step 2 — Add the PostgreSQL JDBC driver dependency Inside the `` block, add the PostgreSQL JDBC driver: ```xml org.postgresql postgresql 42.7.8 ``` > Check [Maven Central](https://central.sonatype.com/artifact/org.postgresql/postgresql) > for the latest version. If the parent POM manages the PostgreSQL version, omit the > `` tag. --- ## Step 3 — Add the Ebean PostgreSQL platform dependency Inside the `` block, add the Ebean Postgres platform dependency: ```xml io.ebean ebean-postgres ${ebean.version} ``` This single artifact pulls in the Ebean core, the datasource connection pool (`ebean-datasource`), and all Postgres-specific support. --- ## Step 4 — Add the ebean-test dependency (test scope) `ebean-test` configures Ebean for tests and enables automatic Docker container management for Postgres test instances: ```xml io.ebean ebean-test ${ebean.version} test ``` --- ## Step 5 — Add the ebean-maven-plugin (bytecode enhancement) Ebean requires bytecode enhancement to provide dirty-checking and lazy-loading. The `ebean-maven-plugin` performs this enhancement at build time. Inside the `` block, add: ```xml io.ebean ebean-maven-plugin ${ebean.version} true ``` --- ## Step 6 — Add the querybean-generator annotation processor 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`. ### Case A — No existing `maven-compiler-plugin` configuration Add the full plugin entry to ``: ```xml org.apache.maven.plugins maven-compiler-plugin 3.15.0 io.ebean querybean-generator ${ebean.version} ``` ### Case B — `maven-compiler-plugin` already exists with `` Locate the existing `` block inside the existing `maven-compiler-plugin` entry and add the new `` inside it. Do **not** add a second `` block or a second `` block. Example — if the existing block already has a path for, say, `avaje-nima-generator`: ```xml io.avaje avaje-nima-generator ${avaje-nima.version} io.ebean querybean-generator ${ebean.version} ``` --- ## Verification Run the following to confirm the POM is valid and the project compiles: ```bash mvn compile -pl ``` Expected result: `BUILD SUCCESS` with no errors from Ebean or the annotation processor. --- ## Next Step Proceed to **Step 2: Configure the Datasource and Ebean Database bean** (`add-ebean-postgres-database-config.md`).