【问题标题】:How to fix 'Unresolved reference: jdbc' when configuring Jooq with Gradle Kotlin DSL使用 Gradle Kotlin DSL 配置 Jooq 时如何修复“未解析的引用:jdbc”
【发布时间】:2020-02-25 14:36:42
【问题描述】:

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

我已按照此处记录的配置步骤进行操作: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 构建吗?
  • @Andrey Building 从终端返回相同的错误

标签: gradle intellij-idea kotlin build.gradle jooq


【解决方案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'
      ...
    }
    ...
  }
}

【讨论】:

  • 谢谢!还有另一个问题:我使用 gradle 多项目构建并在错误的位置调用插件。
猜你喜欢
  • 1970-01-01
  • 2022-01-06
  • 1970-01-01
  • 2019-06-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-18
  • 1970-01-01
相关资源
最近更新 更多