【问题标题】:Execution failed for task ':compileJava'. Gradle任务 ':compileJava' 执行失败。摇篮
【发布时间】:2017-07-20 15:41:06
【问题描述】:

我正在尝试在 Eclipse 中设置我的第一个 gradle 项目,但我在构建 gradle 时遇到了问题。我已经从 spring.io 复制了 build.gradle,但它仍然无法正确构建。我得到任务':compileJava'的执行失败。我的 build.gradle 文件看起来像这样

 buildscript {
repositories {
    mavenCentral()
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.1.RELEASE")
}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'

jar {
baseName = 'gs-spring-boot'
version =  '0.1.0'
}

repositories {
mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
// tag::jetty[]
compile("org.springframework.boot:spring-boot-starter-web") {
    exclude module: "spring-boot-starter-tomcat"
}
compile("org.springframework.boot:spring-boot-starter-jetty")
// end::jetty[]
// tag::actuator[]
compile("org.springframework.boot:spring-boot-starter-actuator")
// end::actuator[]
testCompile("junit:junit")
}

【问题讨论】:

  • 完整输出是什么?请在构建命令中使用“-s”参数。
  • @MartinLinha 错误详情pastebin.com/PgAmm0Sx

标签: java spring eclipse gradle


【解决方案1】:

如上所述,您的构建无法编译

Compilation failed; see the compiler error output for details.

检查代码并找出导致它无法构建的原因。尝试使用-s -i 选项运行命令以找出问题所在。

【讨论】:

    【解决方案2】:

    更改 javahome 变量以指向正确的目录,即指向您的 jdk 主目录。

    在 Eclipse 中,您可以在 Java Home 下的运行配置中更改路径,例如更改为 C:\Program Files\Java\jdk-9.0.4。 然后以cleanassemble 运行配置。

    【讨论】:

      猜你喜欢
      • 2022-11-02
      • 2017-10-10
      • 2015-08-07
      • 1970-01-01
      • 2020-03-07
      • 2020-02-25
      • 2023-03-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多