映射生成的目录和模式
适用于 ✅ 开源版 ✅ 专业版 ✅ 企业版
在之前关于运行时模式映射的章节中,我们已经了解到目录、模式和表可以在运行时映射到其他名称。但是,您也可以在代码生成时硬连线目录和模式映射,例如,当您有 5 个开发人员拥有各自的专用开发数据库和一个公共集成数据库时。在代码生成配置中,您可以这样编写。
模式映射
以下配置仅对模式应用映射,不对目录应用映射。 <schemata/> 元素是一个独立的元素,可以放在代码生成器的 <database/> 配置元素中
XML(独立和 Maven)
编程方式
Gradle (Kotlin)
Gradle (Groovy)
Gradle(第三方)
<configuration>
<generator>
<database>
<schemata>
<schema>
<!-- Use this as the developer's schema: -->
<inputSchema>LUKAS_DEV_SCHEMA</inputSchema>
<!-- Use this as the integration / production database: -->
<outputSchema>PROD</outputSchema>
</schema>
</schemata>
</database>
</generator>
</configuration>
有关更多详细信息,请参阅配置 XSD、独立代码生成和maven 代码生成。
new org.jooq.meta.jaxb.Configuration()
.withGenerator(new Generator()
.withDatabase(new Database()
.withSchemata(
new SchemaMappingType()
// Use this as the developer's schema:
.withInputSchema("LUKAS_DEV_SCHEMA")
// Use this as the integration / production database:
.withOutputSchema("PROD")
)
)
)
import org.jooq.meta.jaxb.*
configuration {
generator {
database {
schemata {
schema {
// Use this as the developer's schema:
inputSchema = "LUKAS_DEV_SCHEMA"
// Use this as the integration / production database:
outputSchema = "PROD"
}
}
}
}
}
有关更多详细信息,请参阅配置 XSD和gradle 代码生成。
configuration {
generator {
database {
schemata {
schema {
// Use this as the developer's schema:
inputSchema = "LUKAS_DEV_SCHEMA"
// Use this as the integration / production database:
outputSchema = "PROD"
}
}
}
}
}
有关更多详细信息,请参阅配置 XSD和gradle 代码生成。
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19. // Please use the official plugin instead of the third party plugin that was recommended before.
以下配置对目录及其模式应用映射。 <catalogs/> 元素是一个独立的元素,可以放在代码生成器的 <database/> 配置元素中
XML(独立和 Maven)
编程方式
Gradle (Kotlin)
Gradle (Groovy)
Gradle(第三方)
<configuration>
<generator>
<database>
<catalogs>
<catalog>
<!-- Use this as the developer's catalog: -->
<inputCatalog>LUKAS_DEV_CATALOG</inputCatalog>
<!-- Use this as the integration / production database: -->
<outputCatalog>PROD</outputCatalog>
<!-- Optionally, nest also schema mapping configurations: -->
<schemata>
</schemata>
</catalog>
</catalogs>
</database>
</generator>
</configuration>
有关更多详细信息,请参阅配置 XSD、独立代码生成和maven 代码生成。
new org.jooq.meta.jaxb.Configuration()
.withGenerator(new Generator()
.withDatabase(new Database()
.withCatalogs(
new CatalogMappingType()
// Use this as the developer's catalog:
.withInputCatalog("LUKAS_DEV_CATALOG")
// Use this as the integration / production database:
.withOutputCatalog("PROD")
// Optionally, nest also schema mapping configurations:
.withSchemata()
)
)
)
import org.jooq.meta.jaxb.*
configuration {
generator {
database {
catalogs {
catalog {
// Use this as the developer's catalog:
inputCatalog = "LUKAS_DEV_CATALOG"
// Use this as the integration / production database:
outputCatalog = "PROD"
// Optionally, nest also schema mapping configurations:
schemata {}
}
}
}
}
}
有关更多详细信息,请参阅配置 XSD和gradle 代码生成。
configuration {
generator {
database {
catalogs {
catalog {
// Use this as the developer's catalog:
inputCatalog = "LUKAS_DEV_CATALOG"
// Use this as the integration / production database:
outputCatalog = "PROD"
// Optionally, nest also schema mapping configurations:
schemata {}
}
}
}
}
}
有关更多详细信息,请参阅配置 XSD和gradle 代码生成。
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19. // Please use the official plugin instead of the third party plugin that was recommended before.
反馈
您对此页面有任何反馈吗? 我们很乐意听取您的意见!