【发布时间】:2019-06-27 09:57:33
【问题描述】:
我在我的应用程序中使用 Jooq 和 Mysql。我们的发布管道遵循 dev -> stage -> prod 。
每个 env 都有相同的架构,但问题是,它们可能有以下变量:
- 它们可能有不同的数据库名称(dev_db、stage_db、prod_db)
- 他们可能有不同的数据库 URL 和凭据
目前,我得到了以下代码。
public static void init() {
Target l_target = new Target();
System.out.println("My directory is::"+l_target.getPackageName());
l_target.setDirectory("src/main/java");
l_target.setPackageName("com.my.paas.css.entity");
Configuration configuration = new Configuration()
.withJdbc(new Jdbc()
.withDriver("com.mysql.jdbc.Driver")
.withUrl("jdbc:mysql://localhost:3306/paas")
.withUser("root"))
.withGenerator(new Generator()
.withDatabase(new Database()
.withName("org.jooq.meta.mysql.MySQLDatabase")
.withIncludes(".*")
.withExcludes("")
.withInputSchema("paas"))
.withTarget(l_target));
try {
GenerationTool.generate(configuration);
} catch (Exception ex) {
System.out.println();
ex.printStackTrace();
}
}
我想了解,如何让代码生成适应环境?
【问题讨论】: