Related: Trouble Shooting

ebeaninit (CLI Tool)

Ebean has a CLI tool that we use to: setup a project with configuration

  • Setup configuration files
  • Setup dependencies and plugins for Maven and Gradle
  • Generate Finders for entities

Install Command line tool

## Linux install

curl -s https://ebean.io/cli-dist/install | bash

This tool can automatically setup a Maven or Gradle project adding test config files, dependencies and plugins.

If you have trouble with the cli install try the manual install instructions.

Setup project

ebeaninit can setup an existing Maven or Gradle project and we are ready to run the sample CustomerTest.

Below shows it being run for a maven project.

$ ebeaninit
-------------------------------------------------------------
ebeaninit  - interactive ebean initialiser - v1.10
-------------------------------------------------------------

It looks like Ebean is not configured for this project.
Do you want to run project setup to add dependencies and configuration ? [y/n] >

Using Java or Kotlin? [j/k] >

Add dependencies and enhancement plugin to pom? [y/n] >
Add JDBC driver dependency?
0 - No, I'll add it myself
p - Postgres
m - MySql or MariaDB
s - SQL Server
o - Oracle
h - Hana
c - Clickhouse
l - Sqlite
Select an option: [0/p/m/s/o/h/c/l] >
...updated pom.xml adding dependencies and enhancement plugin

Add a sample Entity bean? [y/n] >
Enter a package that will contain the entity beans (e.g. org.myapp.domain) >
...added sample code - BaseModel.java, Customer.java and CustomerTest.java

Add ebean.mf manifest to control enhancement? [y/n] >
Select a package that will contain the entity beans
0 - org.myapp.domain
1 - Other
Select an option: [0/1] >
Select the top level package @Transactional is used
0 - org.example.myapp
1 - Other
2 - None, I don't want to use @Transactional
Select an option: [0/1/2] >
... added ebean.mf

Add application-test.yaml to configure testing? [y/n] >
... added application-test.yaml

Add GenerateDbMigration to generate database migrations? [y/n] >
... added GenerateDbMigration.java


Please re-build the project and then you are all set to go.
You can re-run ebeaninit later to generate finders if you like.

Try running CustomerTest ...
Bye

Next: Maven Gradle