使用Gradle Kotlin DSL配置Jooq时如何解决'Unresolved reference:jdbc'

问题描述 投票:1回答:1

当我尝试使用gradle jooq插件(Unresolved reference: jdbc)配置jdbc驱动程序以使用Jooq生成代码时,[[IntelliJ IDEA 2019.2.4(Ultimate Edition)引发https://github.com/etiennestuder/gradle-jooq-plugin

我已遵循此处记录的配置步骤:https://github.com/etiennestuder/gradle-jooq-plugin#configuration

我的build.gradle.kts的内容:(当将jdbc块注释掉时进行编译)

import nu.studer.gradle.jooq.JooqEdition

plugins {
    kotlin("jvm")
    id("nu.studer.jooq") version "3.0.3" apply true
    id("java-library")
}

dependencies {
    compile(kotlin("stdlib"))
    compile("org.postgresql:postgresql:42.2.7")
    compile("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2")
    compile("org.slf4j:slf4j-api:1.7.28")
    compile("ch.qos.logback:logback-classic:1.2.3")
    compile("ch.qos.logback:logback-core:1.2.3")
    compile("org.jooq:jooq")
    jooqRuntime("postgresql:postgresql:9.1-901.jdbc")

}

jooq {
    version = "3.11.11"
    edition = JooqEdition.OSS
    jdbc {
        driver = "org.postgresql.Driver"
        url = "jdbc:postgresql://localhost:5432/postgres"
        user = "postgres"
        password = "postgres"
    }
}

导入更改时Gradle返回的错误是:

core/build.gradle.kts
Unresolved reference: jdbc
Unresolved reference: driver
Unresolved reference: url
Unresolved reference: user
Unresolved reference: password
gradle intellij-idea kotlin build.gradle jooq
1个回答
1
投票

如您正在使用的third-party plugin's readme中所记录,已将jOOQ配置元素放在错误的级别。自述文件中给出的示例为:

jooq {
  version = '3.11.11'
  edition = 'OSS'
  sample(sourceSets.main) { // This is relevant here
    jdbc {
      driver = 'org.postgresql.Driver'
      url = 'jdbc:postgresql://localhost:5432/sample'
      ...
    }
    ...
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.