etiennestuder/gradle-jooq-plugin

How to setup jooq with h2 ,,

Closed this issue · 0 comments

keede7 commented

Hello,,

I've looked for various data, but the example is postgresql, and I tried to make it work simply with h2,

Every time I look for it and change it, I get an error and I'm curious about which part is definitely the problem,

so I'm uploading an issue,,

plugins {
    id 'java'
    id 'org.springframework.boot' version '2.7.13'
    id 'io.spring.dependency-management' version '1.0.15.RELEASE'
    id 'nu.studer.jooq' version '8.2'  // gradle-jooq-plugin
}

group = 'boot'
version = '0.0.1-SNAPSHOT'

java {
    sourceCompatibility = '17'
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-jooq'
    jooqGenerator 'jakarta.xml.bind:jakarta.xml.bind-api:3.0.1'
//    implementation 'org.jooq:jooq:8.2'
    implementation 'org.jooq:jooq-meta:8.2'
    implementation 'org.jooq:jooq-codegen:8.2'

    implementation 'com.h2database:h2'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

tasks.named('test') {
    useJUnitPlatform()
}

configurations {
    jooqGenerator
}

jooq {
    version = dependencyManagement.importedProperties['3.18'] // use jOOQ version defined in Spring Boot
    configurations {
        main {
            generateSchemaSourceOnCompilation = true // default (can be omitted)
            generationTool {
                logging = org.jooq.meta.jaxb.Logging.DEBUG
                jdbc {
                    driver = 'org.h2.Driver'
                    url = 'jdbc:h2:~/test'
                    user = 'sa'
                    password = ''
                }
                generator {
                    name = 'org.jooq.codegen.DefaultGenerator'
                    strategy {
                        name = 'org.jooq.codegen.DefaultGeneratorStrategy'
                    }
                    database {
                        // https://www.jooq.org/doc/3.15/manual/code-generation/codegen-advanced/codegen-config-database/codegen-database-name/
                        // not need,,?
//                        name = 'org.jooq.h2.generated'
                        inputSchema = 'public'

                        includes = '.*' // regex
                        excludes = ''
                    }
                    generate {
                        generatedSerialVersionUID = 'CONSTANT'
                        javaTimeTypes = true    // java.time.*

                        deprecated = false
                        records = true
                        immutablePojos = true
                        fluentSetters = true
                    }
                    target {
                        // packageName = 'nu.studer.sample'
                        packageName = 'org.jooq.h2.generated'
                        // directory = 'build/generated-src/jooq/main'  // default (can be omitted)
                        directory = 'src/main/java'  // default (can be omitted)
                    }
                }
            }
        }
    }
}

I don't know if I'm not good at searching.

If there is any additional information I need to provide, please let me know.