如何修复 "Execution failed for task 'compileJava'" 错误。 (使用 Intellij Idea 和 Gradle)

How do I fix "Execution failed for task 'compileJava'" error. (Using Intellij Idea and Gradle)

好的,我正在使用 Intellij Idea 中的 JDA 编写 Discord Bot,我正在使用 botCommons 进行嵌入。使用 Gradle 并导入 botCommons jar 文件。那是成功的。然而。我试图启动机器人并在控制台中遇到此问题:

Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not find com.afollestad:ason:1.4.16.
     Searched in the following locations:
       - https://jcenter.bintray.com/com/afollestad/ason/1.4.16/ason-1.4.16.pom
       - https://jcenter.bintray.com/com/afollestad/ason/1.4.16/ason-1.4.16.jar
       - https://repo.maven.apache.org/maven2/com/afollestad/ason/1.4.16/ason-1.4.16.pom
       - https://repo.maven.apache.org/maven2/com/afollestad/ason/1.4.16/ason-1.4.16.jar
       - https://jitpack.io/com/afollestad/ason/1.4.16/ason-1.4.16.pom
       - https://jitpack.io/com/afollestad/ason/1.4.16/ason-1.4.16.jar
     Required by:
         project :
         project : > com.github.duncte123:botCommons:fbb8f98

我有我的 build.gradle 文件:

plugins {
    id'java'
    id'application'
    id'com.github.johnrengelman.shadow' version '2.0.4'
}

mainClassName = 'me.ntmnathan.RoryMercury.Main'

version '1.0'

sourceCompatibility = 1.8

repositories {
    jcenter()
    mavenCentral()

    maven { url 'https://jitpack.io' }
}

dependencies {
    compile group: 'net.dv8tion', name: 'JDA', version: '3.8.0_434'
    compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
    compile group: 'com.github.duncte123', name: 'botCommons', version: 'fbb8f98'
    compile group: 'com.afollestad', name: 'ason', version: '1.4.16'

}

compileJava.options.encoding = 'UTF-8'

抱歉,我是 Java Discord Bot Development 的新手,但我们将不胜感激。

com.afollestad:ason:1.4.16 位于:
https://repo.spring.io/libs-release/com/afollestad/ason/1.4.16/

您需要在 repositories 列表中再添加一个存储库:

maven { url 'https://repo.spring.io/libs-release' }


下一次,这个答案找到了:

确定:

  1. 您的 Gradle 构建失败,因为它找不到此依赖项:

    compile group: 'com.afollestad', name: 'ason', version: '1.4.16'
    
  2. 快速 google 搜索确认它似乎在 MavenRepository 上可用:

    https://mvnrepository.com/artifact/com.afollestad/ason/1.4.6

  3. 但是同样的link表明你需要将这个添加到你的build.gradle:

Note: this artifact it located at Spring Plugins repository (https://repo.spring.io/plugins-release/)

  1. 所以改变这个:

    repositories {
       jcenter()
       mavenCentral()
    
       maven { 
         url 'https://jitpack.io'
       }
       maven { 
         url 'https://repo.spring.io/plugins-release/'
       }