I have the following pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.adamg</groupId>
<artifactId>flyway-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>flyway-test</name>
<description>flyway-test</description>
<properties>
<flyway-maven-plugin.version>10.7.1</flyway-maven-plugin.version>
<jooq.version>3.16.12</jooq.version>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>10.10.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.200</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>${jooq.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>10.10.0</version>
<configuration>
<url>jdbc:h2:file:./target/foobardb</url>
<user>sa</user>
<locations>
<location>classpath:db/migration</location>
</locations>
</configuration>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.191</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
I also have two migration scripts un db.migration: V1_1_0__my_first_migration.sql and V2__Add_people.sql.
I was able to run mvn flyway:migrate as well as mvn compile, and when I look at mvn flyway:info, I see the correct table. I also see a file was created under "target/foobardb.mv.db".
However, I then add the following to my plugins section:
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>${jooq.version}</version>
<executions>
<execution>
<id>generate-jooq</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<jdbc>
<driver>org.h2.Driver</driver>
<url>jdbc:h2:file:./target/foobardb</url>
<user>sa</user>
<password></password>
</jdbc>
<generator>
<name>org.jooq.codegen.JavaGenerator</name>
<database>
<name>org.jooq.meta.h2.H2Database</name>
<includes>.*</includes>
<excludes></excludes>
<inputSchema>PUBLIC</inputSchema>
</database>
<target>
<packageName>com.adamg.generated</packageName>
<directory>target/generated-sources/jooq</directory>
</target>
</generator>
</configuration>
</execution>
</executions>
</plugin>
When I run mvn jooq-codegen:generate, I get the following error:
[INFO] --- jooq-codegen:3.16.12:generate (default-cli) @ flyway-test ---
[ERROR] Incorrect configuration of jOOQ code generation tool
[ERROR]
The jOOQ-codegen-maven module's generator configuration is not set up correctly.
This can have a variety of reasons, among which:
- Your pom.xml's <configuration> contains invalid XML according to jooq-codegen-3.16.5.xsd
- There is a version or artifact mismatch between your pom.xml and your commandline
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.999 s
[INFO] Finished at: 2024-03-18T10:13:54+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jooq:jooq-codegen-maven:3.16.12:generate (default-cli) on project flyway-test: Incorrect configuration of jOOQ code generation tool. See error above for details. -> [Help 1]
Can anyone explain to me what is set up wrong?
UPDATE
I moved the configuration tags to be outside of the executions tag, so it now looks like this:
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>${jooq.version}</version>
<executions>
<execution>
<id>generate-jooq</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<jdbc>
<driver>org.h2.Driver</driver>
<url>jdbc:h2:file:./target/foobardb</url>
<user>sa</user>
<password></password>
</jdbc>
<generator>
<name>org.jooq.codegen.JavaGenerator</name>
<database>
<name>org.jooq.meta.h2.H2Database</name>
<includes>.*</includes>
<excludes></excludes>
<inputSchema>PUBLIC</inputSchema>
</database>
<target>
<packageName>com.adamg.generated</packageName>
<directory>target/generated-sources/jooq</directory>
</target>
</generator>
</configuration>
</plugin>
However, I now get the following error:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.062 s
[INFO] Finished at: 2024-03-18T10:20:45+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jooq:jooq-codegen-maven:3.16.12:generate (default-cli) on project flyway-test: Error running jOOQ code generation tool: General error: "java.lang.IllegalStateException: Unable to read the page at p
osition 824633730370 [1.4.200/6]" [50000-200]: Unsupported type 17 [1.4.200/3] -> [Help 1]
jOOQ's code generator plugin will look up the JDBC driver from your project dependencies:
On the other hand, you configured your Flyway plugin to use this:
Both versions of H2 are quite outdated (with open CVEs!), so I suggest updating them both to the latest version. If that's not possible for some reason, at least use the same version for both Flyway and jOOQ (and your runtime).
H2 is known for backwards incompatible changes throughout its recent history, so when you write a database file with an older version and try to read it again with a newer version, there can be problems.