将Gradle应用部署到Heroku

4

我正在学习如何使用Heroku,尝试部署我的Gradle应用程序。我不知道如何解决这个问题。

以下是我的配置信息。

system.properties

java.runtime.version=1.7

build.gradle

...
task wrapper(type: Wrapper) {
    gradleVersion = '1.6'
}

task stage(type: Copy, dependsOn: [clean, build]) {
    from jar.archivePath
    into project.rootDir 
    rename {
        'app.jar'
    }
}
stage.mustRunAfter(clean)

clean << {
    project.file('app.jar').delete()
}

Procfile

web: java -Dserver.port=$PORT -jar app.jar

错误信息

remote: -----> Gradle app detected
remote: -----> Installing OpenJDK 1.7... done
remote: -----> Building Gradle app...
remote:        WARNING: The Gradle buildpack is currently in Beta.
remote: -----> executing ./gradlew stage
remote:        Error: Could not find or load main class     org.gradle.wrapper.GradleWrapperMain
remote:  !     Failed to build app
remote: 
remote:  !     Push rejected, failed to compile Gradle app

我在git中有这个包装器。 但是我不知道为什么它不能工作。 感谢您的帮助。


这似乎处于该网站的主题/非主题边缘。 - anon
请确认您的项目中已经检入了 gradle/wrapper/gradle-wrapper.jar 文件。 - Mark Vieira
你是对的。我没有想到我的全局 gitignore 文件有 .jar。谢谢! - user2891697
我非常确定它已经被部署了,但仍然得到相同的错误... - sparkyspider
1个回答

0

哇哦,部署成功了!最终的Gradle版本是:

group 'com.zzheads'
version '1.0-SNAPSHOT'

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

apply plugin: 'java'
apply plugin: 'spring-boot'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-thymeleaf")
}

task stage {
    dependsOn build
}

Procfile:

web: java -Dserver.port=$PORT $JAVA_OPTS -jar build/libs/countries-1.0-SNAPSHOT.jar

无法在本地测试,因为出现错误

E:\Projects\countries>heroku local -f Procfile.win
[WARN] No ENV file found
17:06:26 web.1   |  "build" ?? ?????? ???????? ??? ?????
17:06:26 web.1   |  ????????, ??????? ?????? ??? ???????? ????.
[DONE] Killing all processes with signal  null
17:06:26 web.1   Exited with exit code 1

最后一件事情要做:应用程序无法正确访问我的/static文件夹,因此所有的.css文件都找不到:/

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接