"Unrecognized Field: http" 在将 dropwizard 项目部署到 heroku 时在 yaml 中

"Unrecognized Field: http" in yaml when deploying dropwizard project to heroku

我有一个非常简单的 dropwizard 项目(基于 Dropwizard hello world),我想将其部署到 heroku。由于我还不能确定的原因,在 heroku 中成功构建后它无法 运行。 运行 本地没问题;我只在 heroku 上看到这个错误:

heroku 日志:

2016-05-11T06:11:35.276279+00:00 heroku[slug-compiler]: Slug compilation started
2016-05-11T06:11:35.276284+00:00 heroku[slug-compiler]: Slug compilation finished
2016-05-11T06:11:35.317873+00:00 heroku[web.1]: State changed from crashed to starting
2016-05-11T06:11:37.914144+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -Ddw.http.port=56125 -Ddw.http.adminPort=56125 -jar target/myapp-1.0-SNAPSHOT.jar server hello-world.yml`
2016-05-11T06:11:39.645193+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2016-05-11T06:11:39.648486+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx350m -Xss512k -Dfile.encoding=UTF-8
2016-05-11T06:11:40.723314+00:00 app[web.1]: hello-world.yml has an error:
2016-05-11T06:11:40.723347+00:00 app[web.1]:   * Unrecognized field at: http
2016-05-11T06:11:40.723348+00:00 app[web.1]:     Did you mean?:
2016-05-11T06:11:40.723372+00:00 app[web.1]:       - metrics
2016-05-11T06:11:40.723373+00:00 app[web.1]:       - server
2016-05-11T06:11:40.723374+00:00 app[web.1]:       - logging
2016-05-11T06:11:40.723374+00:00 app[web.1]:       - defaultName
2016-05-11T06:11:40.723375+00:00 app[web.1]:
2016-05-11T06:11:41.637830+00:00 heroku[web.1]: State changed from starting to crashed
2016-05-11T06:11:41.614715+00:00 heroku[web.1]: Process exited with status 1

据我所知,我的 hello-world.yml 没有 "http" 字段....

defaultName: steve
server:
  type: simple
  applicationContextPath: /
  #adminContextPath: /admin # If you plan to use an admin path, you'll need to also use non-root app path
  connector:
    type: http
    port: 8080

我的 Procfile,很好的衡量标准:

web: java $JAVA_OPTS -Ddw.http.port=$PORT -Ddw.http.adminPort=$PORT -jar target/myapp-1.0-SNAPSHOT.jar server hello-world.yml

我的 yml 文件看起来像这样的原因是我看到 this Google Groups post 关于同样的错误...不幸的是,发布的解决方案似乎对我不起作用。

有什么想法吗?

Dropwizard 将前缀为 'dw' 的任何系统属性合并到其配置中,因此错误实际上是指“-Ddw.http.port=$PORT” - 将其更改为以下内容以匹配您的配置结构文件。

java $JAVA_OPTS -Ddw.server.connector.port=$PORT -jar target/myapp-1.0-SNAPSHOT.jar server hello-world.yml