【问题标题】:Gradle with IntelliJ not loading PostgreSQL JDBC as a dependency使用 IntelliJ 的 Gradle 未将 PostgreSQL JDBC 作为依赖项加载
【发布时间】:2014-06-16 06:48:06
【问题描述】:

我正在尝试为我的下一个项目设置 IntelliJ 以及 Gradle 和 JOOQ。到目前为止,我的 Gradle 文件是这样的:

apply plugin: 'java'
apply plugin: 'jooq'

sourceCompatibility = 1.5
version = '1.0'

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'
}

dependencies {
    compile 'org.jooq:jooq:3.1.0'
    compile 'com.google.guava:guava:14.0'
    compile 'postgresql:postgresql:9.1-901-1.jdbc4'
}

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
    }

    dependencies {
        classpath 'postgresql:postgresql:9.1-901-1.jdbc4'
        classpath 'com.github.ben-manes:gradle-jooq-plugin:0.5'
    }
}

jooq {
   ... snip ...
}

这就是我的外部依赖项(在 IntelliJ 中)的显示方式:

.

不知何故,Gradle 正在下载,IntelliJ 将 jooq 和 guava 识别为我的依赖项的一部分,但 postgresql 没有出现。因此,在执行此操作时(使用 Guava,从 Gradle 加载的依赖项):

List<String> stringList = Lists.newArrayList();

这失败了 ClassNotFoundException:

Class.forName("org.postgresql.Driver").newInstance();

在执行./gradlew build 时,我看到 gradle 输出了它确实从 Maven Central 下载了 postgresql-9.1-901 jar 的事实,但我不知道它保存在哪里。非常感谢任何帮助。

【问题讨论】:

    标签: java maven intellij-idea gradle


    【解决方案1】:

    显然,我真的需要 RTFM。在对 Gradle 脚本进行更改后,我没有从 IntelliJ 中的 Gradle 工具窗口刷新依赖项。从这里得到它:https://www.jetbrains.com/idea/webhelp/synchronizing-changes-in-gradle-project-and-intellij-idea-project.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-26
      • 2015-03-20
      • 1970-01-01
      • 2012-10-25
      • 1970-01-01
      • 2013-11-18
      • 1970-01-01
      • 2015-12-24
      相关资源
      最近更新 更多