eclipse 任务“:compileJava”执行失败。摇篮
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42529580/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Execution failed for task ':compileJava'. Gradle
提问by Oceris
I am trying to set up my first gradle project in eclipse but im having problem with building gradle. I' ve copied build.gradle from spring.io but still it wont build properly. I get Execution failed for task ':compileJava'. My build.gradle file looks like this
我正在尝试在 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")
}
回答by Martin Linha
Your build cannot be compiled, as stated
如上所述,您的构建无法编译
Compilation failed; see the compiler error output for details.
Compilation failed; see the compiler error output for details.
check the code and find what causes it to not to build. Try to run the command with -s -i
options to find out what is wrong.
检查代码并找出导致它无法构建的原因。尝试运行带有-s -i
选项的命令以找出问题所在。
回答by Selva kumaran
Change the javahome variable to point to the proper directory, i.e. to your jdk home directory.
将 javahome 变量更改为指向正确的目录,即您的 jdk 主目录。
In Eclipse you can change the path in a run configuration under Java Home, for example to C:\Program Files\Java\jdk-9.0.4
.
Then run the configuration as clean
and assemble
.
在 Eclipse 中,您可以在 Java Home 下的运行配置中更改路径,例如更改为C:\Program Files\Java\jdk-9.0.4
. 然后以clean
和运行配置assemble
。