java - 如何在 Heroku 上部署 java gradle 应用程序

标签 java heroku gradle web-deployment procfile

请帮助在 Heroku 上部署我的应用程序。 从 Heroku 获取错误消息 *

"Application Error. An error occurred in the application and your page could not be served. Please try again in a few moments. If you are the application owner, check your logs for details."

这里是来自 Heroku 的日志:

2016-07-21T22:11:30.966800+00:00 heroku[slug-compiler]: Slug compilation 
started 2016-07-21T22:11:30.773385+00:00 heroku[api]: Release v8 created by 
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="077d7d6f6266637447606a666e6b2964686a" rel="noreferrer noopener nofollow">[email protected]</a> 2016-07-21T22:11:56.184847+00:00 heroku[router]: at=error 
code=H14 desc="No web processes running" method=GET path="/favicon.ico" 
host=zzheads-countries.herokuapp.com request_id=a03c9276-b038-4f9f-8e6d-
5f29f14b441 fwd="5.3.141.153" dyno= connect= service= status=503 bytes=

我的 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
}

还有我的 Proc 文件:

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

最佳答案

您的构建可能会在目录 build/libs 中生成一个可执行 JAR 文件。在您的 Procfile 中尝试一下:

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

您可以通过运行以下命令在本地测试它:

$ ./gradlew stage
$ heroku local

关于java - 如何在 Heroku 上部署 java gradle 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38515588/

相关文章:

java - 为什么我要使用一个 JVM 而不是另一个?

java - While 循环不检查所有条件

java - YouTube 自动生成的字幕文件具有非顺序时序

ssl - 有什么方法可以在免费的 heroku dyno 上添加免费的 SSL 证书?

heroku - 在 Heroku 上使用 Google 的 TextToSpeech API

python - 从我的电脑访问 Heroku Bonsai 上的 elasticsearch

gradle - 如何将 Gradle 插件(及其依赖项)加载到 build.gradle 中?

java - JAVA 中将文件或 byte[] 转换为 BLOB

Android实验gradle源码

java - gradle bootRun成功启动,但一段时间后断开连接