无法使用 liquibase 架构 xml 文件使用 jOOQ 自动代码生成器生成公共文件

发布于 2025-01-16 09:50:49 字数 3993 浏览 3 评论 0原文

我正在使用 Liquibase 架构 xml 文件通过 jOOQ 自动生成代码。 如果我使用数据库连接进行生成,那么它会在生成的文件夹中创建公共文件,但对于 liquibase 架构则不会。

我希望公共文件出现在生成的文件夹中。现在仅显示这些文件 -

在此处输入图像描述

我尝试将 pom.xml 作为 PUBLIC/public/Public 提供,但没有帮助。

为什么我需要公共文件? - 我想使用Table table = PUBLIC.getTable("sometable") 获取所有存在的表。

这是 pom.xml 配置:

<plugin>
            <groupId>org.jooq</groupId>
            <artifactId>jooq-codegen-maven</artifactId>
            <version>3.15.5</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>

            <dependencies>
                <dependency>
                    <groupId>org.postgresql</groupId>
                    <artifactId>postgresql</artifactId>
                    <version>42.2.12</version>
                </dependency>
            </dependencies>

            <configuration>
                <generator>
                    <database>
                        <name>org.jooq.meta.extensions.liquibase.LiquibaseDatabase</name>

                        <properties>

                            <property>
                                <key>scripts</key>
                                <value>${basedir}/src/main/resources/database.xml</value>
                            </property>

                            <property>
                                <key>includeLiquibaseTables</key>
                                <value>true</value>
                            </property>
                        </properties>
                    </database>

                    <target>
                        <packageName>jooqGenerated</packageName>
                        <directory>target/generated-sources/jooq</directory>
                    </target>
                </generator>
            </configuration>
        </plugin>

这是 liquibase 脚本:

<?xml version="1.0" encoding="UTF-8"?> <databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
               xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd"
               >
<changeSet author="Divyanshi (generated)" id="1647260645913-14">
    <preConditions onFail="MARK_RAN">
        <not>
            <tableExists tableName="toBeDeleted2" schemaName="public"/>
        </not>
    </preConditions>
    <createTable tableName="toBeDeleted2" schemaName="public">
        <column autoIncrement="true" name="id" type="BIGINT">
            <constraints primaryKey="true" primaryKeyName="toBeDeleted2_pkey"/>
        </column>
        <column name="addedAt" type="numeric"/>
        <column name="endTime" type="numeric"/>
        <column name="startTime" type="numeric"/>
        <column name="intervalCount" type="INT"/>
        <column name="targetTable" type="VARCHAR(100)"/>
        <column name="updatedColumn2" type="numeric"/>
    </createTable>
</changeSet>


<changeSet author="Divyanshi" id="finalUpdate">
    <renameColumn tableName="toBeDeleted2" remarks="finalUpdate update" oldColumnName="updatedColumn2"
                  newColumnName="finalUpdate" schemaName="public"/>
</changeSet>

I'm using Liquibase schema xml file to auto-generate code with jOOQ.
If I use db connection for generation, then it creates the Public file in generated folder, but with liquibase schema it doesn't.

I want Public file to appear in the generated folder. Right now only these files appear -

enter image description here

I have tried giving in pom.xml as PUBLIC/public/Public but it isn't helping.

Why do I need Public file? -
I want to use Table<?> table = PUBLIC.getTable("sometable") to get all the tables present.

Here is the pom.xml configuration:

<plugin>
            <groupId>org.jooq</groupId>
            <artifactId>jooq-codegen-maven</artifactId>
            <version>3.15.5</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>

            <dependencies>
                <dependency>
                    <groupId>org.postgresql</groupId>
                    <artifactId>postgresql</artifactId>
                    <version>42.2.12</version>
                </dependency>
            </dependencies>

            <configuration>
                <generator>
                    <database>
                        <name>org.jooq.meta.extensions.liquibase.LiquibaseDatabase</name>

                        <properties>

                            <property>
                                <key>scripts</key>
                                <value>${basedir}/src/main/resources/database.xml</value>
                            </property>

                            <property>
                                <key>includeLiquibaseTables</key>
                                <value>true</value>
                            </property>
                        </properties>
                    </database>

                    <target>
                        <packageName>jooqGenerated</packageName>
                        <directory>target/generated-sources/jooq</directory>
                    </target>
                </generator>
            </configuration>
        </plugin>

Here is the liquibase script:

<?xml version="1.0" encoding="UTF-8"?> <databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
               xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd"
               >
<changeSet author="Divyanshi (generated)" id="1647260645913-14">
    <preConditions onFail="MARK_RAN">
        <not>
            <tableExists tableName="toBeDeleted2" schemaName="public"/>
        </not>
    </preConditions>
    <createTable tableName="toBeDeleted2" schemaName="public">
        <column autoIncrement="true" name="id" type="BIGINT">
            <constraints primaryKey="true" primaryKeyName="toBeDeleted2_pkey"/>
        </column>
        <column name="addedAt" type="numeric"/>
        <column name="endTime" type="numeric"/>
        <column name="startTime" type="numeric"/>
        <column name="intervalCount" type="INT"/>
        <column name="targetTable" type="VARCHAR(100)"/>
        <column name="updatedColumn2" type="numeric"/>
    </createTable>
</changeSet>


<changeSet author="Divyanshi" id="finalUpdate">
    <renameColumn tableName="toBeDeleted2" remarks="finalUpdate update" oldColumnName="updatedColumn2"
                  newColumnName="finalUpdate" schemaName="public"/>
</changeSet>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文