我正在尝试为Spring Boot和Gradle设置基本工作区。
一切在本地和travis中都可以正常运行,但是在heroku中构建失败。我认为问题不在实际代码中,而在配置中。
这是我在github.中的项目
build.gradle
plugins {
id 'java'
id 'maven'
id 'jacoco'
id 'org.springframework.boot' version '1.5.3.RELEASE'
}
group = 'org.karlin'
version = '0.1.0'
sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
bootRepackage {
mainClass = 'gramise.Gramise'
}
repositories {
maven {
url("https://plugins.gradle.org/m2/")
}
}
dependencies {
compile("com.google.code.gson:gson")
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.postgresql:postgresql")
compile("org.apache.commons:commons-dbcp2")
compile("com.h2database:h2")
testCompile(group: 'org.springframework.boot', name: 'spring-boot-
starter-test', version:'1.5.3.RELEASE') {
exclude(module: 'commons-logging')
}
testCompile group: 'com.jayway.jsonpath', name: 'json-path', version:'2.2.0'
}
task stage(dependsOn: ['build', 'clean'])
build.mustRunAfter clean
有heroku构建日志
-----> Gradle app detected
-----> Installing OpenJDK 1.8... done
-----> Installing Gradle Wrapper...
WARNING: Your application does not have it's own gradlew file.
-----> Building Gradle app...
-----> executing ./gradlew build
Download https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-gradle-plugin/1.5.3.RELEASE/spring-boot-gradle-plugin-1.5.3.RELEASE.pom
Download https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-tools/1.5.3.RELEASE/spring-boot-tools-1.5.3.RELEASE.pom
Download https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-loader-tools/1.5.3.RELEASE/spring-boot-loader-tools-1.5.3.RELEASE.pom
Download https://plugins.gradle.org/m2/io/spring/gradle/dependency-management-plugin/1.0.2.RELEASE/dependency-management-plugin-1.0.2.RELEASE.pom
Download https://plugins.gradle.org/m2/org/springframework/spring-core/4.3.8.RELEASE/spring-core-4.3.8.RELEASE.pom
Download https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-gradle-plugin/1.5.3.RELEASE/spring-boot-gradle-plugin-1.5.3.RELEASE.jar
Download https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-loader-tools/1.5.3.RELEASE/spring-boot-loader-tools-1.5.3.RELEASE.jar
Download https://plugins.gradle.org/m2/io/spring/gradle/dependency-management-plugin/1.0.2.RELEASE/dependency-management-plugin-1.0.2.RELEASE.jar
Download https://plugins.gradle.org/m2/org/springframework/spring-core/4.3.8.RELEASE/spring-core-4.3.8.RELEASE.jar
FAILURE: Build failed with an exception.
* What went wrong:
org/gradle/api/plugins/JavaPlugin
> org.gradle.api.plugins.JavaPlugin
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
最佳答案
您需要将gradlew
检入Git。
WARNING: Your application does not have it's own gradlew file.
因为您没有执行此操作,所以Heroku使用了非常旧的Gradle版本。
关于java - 为什么heroku构建由于gradle和spring boot而失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45817476/