Gradle java web应用程序并不是从heroku开始的

时间:2016-05-15 16:16:25

标签: java heroku web-applications gradle gradlew

当我使用

在本地部署我的应用时
heroku local

它启动了,但是当我将它推到远程时,heroku toolbelt没有显示任何错误,但这是我从日志中得到的:

2016-05-15T16:00:13.504799+00:00 heroku[slug-compiler]: Slug  compilation started
2016-05-15T16:00:13.504808+00:00 heroku[slug-compiler]: Slug compilation finished
2016-05-15T16:00:19.131289+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=damp-ocean-4271.herokuapp.com request_id=d0d12240-3923-467f-bf21-84bb5bcd79ca fwd="46.53.183.156" dyno= connect= service= status=503 bytes=

我正在使用本指南https://devcenter.heroku.com/articles/deploying-gradle-apps-on-heroku

Procfile

web: cd build ; java -jar ../build/server/webapp-runner-*.jar --expand-war --port $PORT libs/*.war

的build.gradle

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'maven'

group = 'com.ily'
version = '1.1-SNAPSHOT'

description = """web"""

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
  mavenLocal()
  maven { url "http://repo1.maven.org/maven2" }
  maven { url "http://repository.jboss.org/nexus/content/groups/public/" }
}
dependencies {
  compile group: 'org.mybatis', name: 'mybatis', version:'3.3.0'
  compile group: 'org.mybatis', name: 'mybatis-spring', version:'1.2.3'
  compile group: 'org.springframework', name: 'spring-jdbc',  version:'4.2.2.RELEASE'
  compile group: 'javax.servlet', name: 'javax.servlet-api', version:'3.1.0'
  compile group: 'javax.servlet', name: 'jstl', version:'1.2'
  compile group: 'com.mashape.unirest', name: 'unirest-java', version:'1.4.5'
  compile group: 'org.postgresql', name: 'postgresql', version:'9.4-1201-jdbc4'
  compile group: 'org.springframework', name: 'spring-core', version:'4.2.2.RELEASE'
  compile group: 'org.springframework', name: 'spring-test', version:'4.2.2.RELEASE'
  compile group: 'org.springframework', name: 'spring-web', version:'4.2.2.RELEASE'
  compile group: 'org.springframework', name: 'spring-webmvc', version:'4.2.2.RELEASE'
  compile group: 'org.bitbucket.b_c', name: 'jose4j', version:'0.4.4'
  compile group: 'com.fasterxml.jackson.jaxrs', name: 'jackson-jaxrs-json-provider', version:'2.6.2'
  compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.7'
  compile group: 'org.slf4j', name: 'slf4j-log4j12', version:'1.7.7'
  compile group: 'org.slf4j', name: 'jcl-over-slf4j', version:'1.7.7'
  compile group: 'log4j', name: 'log4j', version:'1.2.17'
  compile group: 'org.eclipse.jetty', name: 'jetty-servlet',    version:'9.2.10.v20150310'
  compile 'com.github.jsimone:webapp-runner:8.0.30.2'
  testCompile group: 'org.testng', name: 'testng', version:'6.9.6'
}

task stage() {
  dependsOn clean, war
}
tasks.stage.doLast() {
  delete fileTree(dir: "build/distributions")
  delete fileTree(dir: "build/assetCompile")
  delete fileTree(dir: "build/distributions")
  delete fileTree(dir: "build/libs", exclude: "*.war")
}
war.mustRunAfter clean

task copyToLib(type: Copy) {
  into "$buildDir/server"
  from(configurations.compile) {
    include "webapp-runner*"
  }
}

stage.dependsOn(copyToLib)

1 个答案:

答案 0 :(得分:4)

我认为您可能没有打开任何网络动态。你可以使用' ps'来检查有多少dynos在运行。命令:

grails.plugin.springsecurity.filterChain.chainMap = [
    //Stateless chain
    [
        pattern: '/api/**',
        filters: 'JOINED_FILTERS,-anonymousAuthenticationFilter,-exceptionTranslationFilter,-authenticationProcessingFilter,-securityContextPersistenceFilter,-rememberMeAuthenticationFilter'
    ],

    //Traditional chain
    [
        pattern: '/**',
        filters: 'JOINED_FILTERS,-restTokenValidationFilter,-restExceptionTranslationFilter'
    ]
]

然后,您可以像这样扩展应用程序的网络动态:

>> heroku ps

上面的命令会将您的应用程序设置为1个web dyno。

有关详细信息,请参阅此页面https://devcenter.heroku.com/articles/getting-started-with-java#scale-the-app