Spring boot Flyway Jooq Code gen maven 插件顺序

Spring boot Flyway Jooq Code gen maven plugin order

如何强制 flyway:migrate 始终在 jooq:generate-sources 之前执行? 我正在使用带有 spring boot.

的 Maven 包装器
<plugin>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-maven-plugin</artifactId>
            <version>6.3.3</version>
        </plugin>
        <plugin>
            <groupId>org.jooq</groupId>
            <artifactId>jooq-codegen-maven</artifactId>
            <version>3.13.1</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <generator>
                    <database>
                        <name>org.jooq.meta.postgres.PostgresDatabase</name>
                        <inputSchema>public</inputSchema>
                    </database>
                    <target>
                        <packageName>bg.kotz.db</packageName>
                        <directory>src/main/java</directory>
                    </target>
                </generator>
            </configuration>
        </plugin>

您还必须将 executions 块添加到 flyway-maven-plugin 部分,以便在 generate-sources 步骤下执行迁移:

<plugin>
  <groupId>org.flywaydb</groupId>
  <artifactId>flyway-maven-plugin</artifactId>
  <version>6.3.3</version>
  <executions>
     <execution>
        <phase>generate-sources</phase>
        <goals>
            <goal>migrate</goal>
        </goals>
     </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.jooq</groupId>
  <artifactId>jooq-codegen-maven</artifactId>
  <version>3.13.1</version>
  <executions>
     <execution>
        <phase>generate-sources</phase>
        <goals>
            <goal>generate</goal>
        </goals>
     </execution>
  </executions>
  <configuration>
    <generator>
       <database>
          <name>org.jooq.meta.postgres.PostgresDatabase</name>
          <inputSchema>public</inputSchema>
        </database>
        <target>
          <packageName>bg.kotz.db</packageName>
          <directory>src/main/java</directory>
        </target>
      </generator>
    </configuration>
  </plugin>
</plugins>

当您在 src/main/java 中生成代码时,Maven 中的所有内容都开始崩溃。最好保持默认生成到 target/...,或者,如果你想签入生成的源,为 Flyway 迁移和 jOOQ 代码生成创建单独的 Maven 项目