我如何使用 liquibase 和没有数据库连接属性设置 jooq-codegen-maven 插件的 postgres 方言
How can i setup the postgres dialect of jooq-codegen-maven plugin with liquibase and without db connection properties
我使用 liquibase 和 jooq,我需要直接从 liquibase xml 文件生成我的 pojo,但我无法用 Postgres 覆盖默认的“H2”方言。实际上,我已经尝试在插件“配置”部分通过 属性 设置方言,但它仍然使用 H2。有人可以问我如何让 jooq 在读取 xml 文件和生成 java 类.
时使用 postgres 方言
这里是使用的库版本
<properties>
<jooq.version>3.13.4</jooq.version>
<vertx-jooq.version>5.1.1</vertx-jooq.version>
<postgres.version>42.2.12</postgres.version>
</properties>
这是我的插件配置
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>${jooq.version}</version>
<executions>
<execution>
<id>jooq-generate</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgres.version}</version>
</dependency>
<dependency>
<groupId>io.github.jklingsporn</groupId>
<artifactId>vertx-jooq-generate</artifactId>
<version>${vertx-jooq.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.3.9</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta-extensions</artifactId>
<version>${jooq.version}</version>
</dependency>
</dependencies>
<configuration>
<generator>
<name>io.github.jklingsporn.vertx.jooq.generate.classic.ClassicReactiveVertxGenerator</name>
<database>
<name>org.jooq.meta.extensions.liquibase.LiquibaseDatabase</name>
<properties>
<property>
<key>scripts</key>
<value>src/main/resources/liquibase/tenant/changelog.xml</value>
</property>
<property>
<key>changeLogParameters.contexts</key>
<value>!test</value>
</property>
<-- unfortunately this property doesn't work -->
<property>
<key>dialect</key>
<value>POSTGRES</value>
</property>
</properties>
<outputSchemaToDefault>true</outputSchemaToDefault>
<unsignedTypes>false</unsignedTypes>
<forcedTypes />
</database>
<generate>
<daos>true</daos>
<fluentSetters>true</fluentSetters>
</generate>
<target>
<packageName>org.folio.rest.jooq</packageName>
</target>
<strategy>
<name>io.github.jklingsporn.vertx.jooq.generate.VertxGeneratorStrategy</name>
</strategy>
</generator>
</configuration>
</plugin>
从 jOOQ 3.14 开始,org.jooq.meta.extensions.liquibase.LiquibaseDatabase
data source for the jOOQ code generator uses H2 behind the scenes to simulate a migration, instead of actually running the migration on your target database. This allows for working with jOOQ and your liquibase migration scripts without an actual database instance and connection. In the future, it might be possible to spin up a PostgreSQL instance, transparently, using testcontainers: https://github.com/jOOQ/jOOQ/issues/6551
以下是如何设置的示例:
https://github.com/jOOQ/jOOQ/tree/main/jOOQ-examples/jOOQ-testcontainers-example(不太难)
如果您希望使用实际的 PostgreSQL 数据库,只需 运行 在 运行 jOOQ 代码生成之前使用 liquibase maven 插件进行 liquibase 迁移,同时连接到同一数据库服务器.
我使用 liquibase 和 jooq,我需要直接从 liquibase xml 文件生成我的 pojo,但我无法用 Postgres 覆盖默认的“H2”方言。实际上,我已经尝试在插件“配置”部分通过 属性 设置方言,但它仍然使用 H2。有人可以问我如何让 jooq 在读取 xml 文件和生成 java 类.
时使用 postgres 方言这里是使用的库版本
<properties>
<jooq.version>3.13.4</jooq.version>
<vertx-jooq.version>5.1.1</vertx-jooq.version>
<postgres.version>42.2.12</postgres.version>
</properties>
这是我的插件配置
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>${jooq.version}</version>
<executions>
<execution>
<id>jooq-generate</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgres.version}</version>
</dependency>
<dependency>
<groupId>io.github.jklingsporn</groupId>
<artifactId>vertx-jooq-generate</artifactId>
<version>${vertx-jooq.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.3.9</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta-extensions</artifactId>
<version>${jooq.version}</version>
</dependency>
</dependencies>
<configuration>
<generator>
<name>io.github.jklingsporn.vertx.jooq.generate.classic.ClassicReactiveVertxGenerator</name>
<database>
<name>org.jooq.meta.extensions.liquibase.LiquibaseDatabase</name>
<properties>
<property>
<key>scripts</key>
<value>src/main/resources/liquibase/tenant/changelog.xml</value>
</property>
<property>
<key>changeLogParameters.contexts</key>
<value>!test</value>
</property>
<-- unfortunately this property doesn't work -->
<property>
<key>dialect</key>
<value>POSTGRES</value>
</property>
</properties>
<outputSchemaToDefault>true</outputSchemaToDefault>
<unsignedTypes>false</unsignedTypes>
<forcedTypes />
</database>
<generate>
<daos>true</daos>
<fluentSetters>true</fluentSetters>
</generate>
<target>
<packageName>org.folio.rest.jooq</packageName>
</target>
<strategy>
<name>io.github.jklingsporn.vertx.jooq.generate.VertxGeneratorStrategy</name>
</strategy>
</generator>
</configuration>
</plugin>
从 jOOQ 3.14 开始,org.jooq.meta.extensions.liquibase.LiquibaseDatabase
data source for the jOOQ code generator uses H2 behind the scenes to simulate a migration, instead of actually running the migration on your target database. This allows for working with jOOQ and your liquibase migration scripts without an actual database instance and connection. In the future, it might be possible to spin up a PostgreSQL instance, transparently, using testcontainers: https://github.com/jOOQ/jOOQ/issues/6551
以下是如何设置的示例: https://github.com/jOOQ/jOOQ/tree/main/jOOQ-examples/jOOQ-testcontainers-example(不太难)
如果您希望使用实际的 PostgreSQL 数据库,只需 运行 在 运行 jOOQ 代码生成之前使用 liquibase maven 插件进行 liquibase 迁移,同时连接到同一数据库服务器.