在Heroku中部署我的Gradle(Spring Boot)应用程序

时间:2016-10-30 14:41:59

标签: heroku github gradle spring-boot

我有一个gradle + spring启动应用程序,带有以下build.gradle文件:

buildscript {
    ext {
        springBootVersion = '2.0.0.BUILD-SNAPSHOT'
    }
    repositories {
        mavenCentral()
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

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

jar {
    baseName = 'teambuilting'
    version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
    maven { url "https://repo.spring.io/snapshot" }
    maven { url "https://repo.spring.io/milestone" }
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter-actuator')
    compile('org.springframework.boot:spring-boot-actuator-docs')
    compile('org.springframework.boot:spring-boot-starter-data-rest')
    compile('org.springframework.data:spring-data-rest-hal-browser')
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework.boot:spring-boot-starter-web-services')
    compile('org.springframework.boot:spring-boot-starter-data-mongodb')

    testCompile('org.springframework.boot:spring-boot-starter-test')
}

但是,当我尝试在Heroku中部署我的主分支时,我收到以下错误:

-----> Failed to detect set buildpack https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/gradle.tgz
More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
 !     Push failed

我在Buildpacks中添加了heroku / gradle。我还缺少什么?

1 个答案:

答案 0 :(得分:1)

您必须在仪表板中定义项目使用Gradle的buildpack。在build.gradle中,必须添加此任务:

task stage {
    dependsOn build
}

并创建一个Procfile,以指示heroku构建软件后的后续步骤。

Juan Antonio