【问题标题】:Kotlin Require Library with Gradle Build带有 Gradle 构建的 Kotlin Require 库
【发布时间】:2017-09-06 19:55:25
【问题描述】:

我正在尝试将库 Exposed 添加到我的项目中。所以,它把我带到了the bintray page,它说要使用compile 'org.jetbrains.exposed:exposed:0.8.5'。我打开我的文件build.gradle 并将该文件放入dependencies 段中:

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
    compile 'org.jetbrains.exposed:exposed:0.8.5'
}

IntelliJ 自动构建它,我收到以下错误

警告:根项目“DB-Table-To-Orm”:无法构建 Kotlin 项目配置详情: java.lang.reflect.InvocationTargetException: null 原因: org.gradle.api.artifacts.ResolveException:无法解决所有问题 配置“:compileClasspath”的依赖项。造成的: org.gradle.internal.resolve.ModuleVersionNotFoundException:不能 找到 org.jetbrains.exposed:exposed:0.8.5。在以下搜索 地点: https://repo1.maven.org/maven2/org/jetbrains/exposed/exposed/0.8.5/exposed-0.8.5.pom https://repo1.maven.org/maven2/org/jetbrains/exposed/exposed/0.8.5/exposed-0.8.5.jar 要求: 项目:

所以,我查看in the repo 并没有超出jetbrains 的路径与exposed 目录。

如何使用 Gradle 安装 Exposed 库?他们的路径写错了吗?我应该在项目中提交错误报告吗?还是我只是将compile 语句放在错误的位置?

抱歉,如果这看起来是一个愚蠢的请求,我是 JavalandKotlinIntelliJ 的新手。为.NET 世界而来。

更新

这是build.gradle 的全部内容:

group 'com.awebsite.db-table-to-orm'
version '1.0-SNAPSHOT'

buildscript {
    ext.kotlin_version = '1.1.4-2'

    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

apply plugin: 'kotlin'

repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
    compile 'org.jetbrains.exposed:exposed:0.8.5'
}

compileKotlin {
    kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
}

【问题讨论】:

  • 你能发布你的 build.gradle 和 repositories 块吗?
  • @GabrieleMariotti 发布了build.gradle 文件。请注意,在该项目的 bintray 网页中,它表示该位置位于 https://dl.bintray.com/kotlin/exposed

标签: gradle kotlin kotlin-exposed


【解决方案1】:

据我所知,Exposed 不在主要的 bintray 存储库(又名 jcenter)中。要在 Exposed 的仓库中进行 gradle 搜索,您需要添加以下内容:

maven {
    url  "https://dl.bintray.com/kotlin/exposed" 
}

到您的repositories 部分。

例子:

repositories {
    mavenCentral()
    maven {
        url  "https://dl.bintray.com/kotlin/exposed" 
    }
}

然后重建,它应该可以正常工作

【讨论】:

  • 我添加了jcenter() 另一个是mavenCentral()。它在jcenter.bintray.com 中查找,但没有找到。我注意到在右上角它说它位于https://dl.bintray.com/kotlin/exposed 下,它确实有图书馆。但是dl() 不起作用。不知道如何将其从jcenter 指向dl
  • 这似乎成功了。除了它不喜欢maven() 我不得不将其更改为mavenCentral() 并且它工作正常。不知道为什么它不喜欢前者。
  • @Jon49 我对maven() 不好。我是凭记忆写的,你可以看到我的记忆有点让我失望。我现在已经编辑了答案
猜你喜欢
  • 1970-01-01
  • 2018-10-19
  • 1970-01-01
  • 2016-01-28
  • 1970-01-01
  • 2018-05-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多