"无法识别的字段:http"在yaml中将dropwizard项目部署到heroku时

时间:2016-05-11 06:21:06

标签: java heroku yaml dropwizard

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

heroku日志:

MainWindow win = (MainWindow)Application.Current.MainWindow;

据我所知,我的hello-world.yml并没有" http"场....

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

我的Procfile,好的措施:

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

我的yml文件看起来是这样的原因是我看到this Google Groups post有关同一错误的信息......遗憾的是,发布的解决方案对我来说似乎不起作用。

有什么想法吗?

1 个答案:

答案 0 :(得分:4)

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
#