CLI 工具 - ebeaninit

Ebean 有一个 CLI 工具,我们使用它来:使用配置设置项目

  • 设置配置文件
  • 为 Maven 和 Gradle 设置依赖项和插件
  • 添加代码以生成数据库迁移
  • 为实体生成查找器

安装命令行工具

## Linux install

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

此工具可以自动设置 Maven 或 Gradle 项目,添加测试配置文件、依赖项和插件。

如果您在 cli 安装中遇到问题,请尝试 手动安装 说明。

设置项目

ebeaninit 可以设置现有的 Maven 或 Gradle 项目,我们就可以运行示例 CustomerTest。

下面显示了针对 maven 项目运行的情况。

$ 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