在 heroku 上使用 mongodb 部署 jhipster 网关
Deploy jhipster gateway with mongodb on heroku
使用 jhipster 5.7.2.
我正在尝试根据 the documentation
将使用 jhipster 创建的网关部署到 heroku
网关正在使用 mongodb 并在我的机器上运行。直接使用本地 mongodb 和 docker-compose 测试了应用程序。一切正常。
然后我尝试在 heroku 上部署它:
jhipster heroku
但是启动失败:
2019-01-07T23:37:16.326055+00:00 app[web.1]: java.lang.IllegalArgumentException: Invalid argument syntax: --spring.data.mongodb.database=
2019-01-07T23:37:16.326066+00:00 app[web.1]: at org.springframework.core.env.SimpleCommandLineArgsParser.parse(SimpleCommandLineArgsParser.java:75)
2019-01-07T23:37:16.326074+00:00 app[web.1]: at org.springframework.core.env.SimpleCommandLinePropertySource.<init>(SimpleCommandLinePropertySource.java:90)
2019-01-07T23:37:16.326076+00:00 app[web.1]: at org.springframework.boot.DefaultApplicationArguments$Source.<init>(DefaultApplicationArguments.java:76)
2019-01-07T23:37:16.326078+00:00 app[web.1]: at org.springframework.boot.DefaultApplicationArguments.<init>(DefaultApplicationArguments.java:42)
2019-01-07T23:37:16.326081+00:00 app[web.1]: at org.springframework.boot.SpringApplication.run(SpringApplication.java:295)
2019-01-07T23:37:16.326122+00:00 app[web.1]: at com.lastcall.gateway.GatewayApp.main(GatewayApp.java:66)
2019-01-07T23:37:16.326397+00:00 app[web.1]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2019-01-07T23:37:16.326400+00:00 app[web.1]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
正如我在控制台中看到的那样,heroku 执行的完整命令是:
`java $JAVA_OPTS -Xmx256m -jar target/*.war --spring.profiles.active=prod,heroku,no-liquibase --server.port=4838 --spring.data.mongodb.database=$(echo "$MONGODB_URI" | sed "s/^.*:[0-9]*\///g")`
从这里我不确定下一步该去哪里。它应该开箱即用,还是我错过了一些步骤?
我想我应该在 heroku 上为自己安装 mongodb 但我不确定。
也欢迎任何有关托管 jhipster 微服务架构的相关建议。
提前致谢:)
更新:
实际上,部署命令中提到的环境变量 'MONGODB_URI' 并未在服务器上设置。此时我假设我应该手动创建一个 mongodb 服务器并设置这个变量 ?
您必须为您的 Heroku 应用程序安装 MongoDB 附加组件,您可以在 Heroku 页面上或通过 运行:
heroku addons:create mongolab
之后,将设置环境变量MONGODB_URI。
可以在 https://devcenter.heroku.com/articles/mongolab 找到更多信息。
使用 jhipster 5.7.2.
我正在尝试根据 the documentation
将使用 jhipster 创建的网关部署到 heroku网关正在使用 mongodb 并在我的机器上运行。直接使用本地 mongodb 和 docker-compose 测试了应用程序。一切正常。
然后我尝试在 heroku 上部署它:
jhipster heroku
但是启动失败:
2019-01-07T23:37:16.326055+00:00 app[web.1]: java.lang.IllegalArgumentException: Invalid argument syntax: --spring.data.mongodb.database=
2019-01-07T23:37:16.326066+00:00 app[web.1]: at org.springframework.core.env.SimpleCommandLineArgsParser.parse(SimpleCommandLineArgsParser.java:75)
2019-01-07T23:37:16.326074+00:00 app[web.1]: at org.springframework.core.env.SimpleCommandLinePropertySource.<init>(SimpleCommandLinePropertySource.java:90)
2019-01-07T23:37:16.326076+00:00 app[web.1]: at org.springframework.boot.DefaultApplicationArguments$Source.<init>(DefaultApplicationArguments.java:76)
2019-01-07T23:37:16.326078+00:00 app[web.1]: at org.springframework.boot.DefaultApplicationArguments.<init>(DefaultApplicationArguments.java:42)
2019-01-07T23:37:16.326081+00:00 app[web.1]: at org.springframework.boot.SpringApplication.run(SpringApplication.java:295)
2019-01-07T23:37:16.326122+00:00 app[web.1]: at com.lastcall.gateway.GatewayApp.main(GatewayApp.java:66)
2019-01-07T23:37:16.326397+00:00 app[web.1]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2019-01-07T23:37:16.326400+00:00 app[web.1]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
正如我在控制台中看到的那样,heroku 执行的完整命令是:
`java $JAVA_OPTS -Xmx256m -jar target/*.war --spring.profiles.active=prod,heroku,no-liquibase --server.port=4838 --spring.data.mongodb.database=$(echo "$MONGODB_URI" | sed "s/^.*:[0-9]*\///g")`
从这里我不确定下一步该去哪里。它应该开箱即用,还是我错过了一些步骤? 我想我应该在 heroku 上为自己安装 mongodb 但我不确定。 也欢迎任何有关托管 jhipster 微服务架构的相关建议。
提前致谢:)
更新: 实际上,部署命令中提到的环境变量 'MONGODB_URI' 并未在服务器上设置。此时我假设我应该手动创建一个 mongodb 服务器并设置这个变量 ?
您必须为您的 Heroku 应用程序安装 MongoDB 附加组件,您可以在 Heroku 页面上或通过 运行:
heroku addons:create mongolab
之后,将设置环境变量MONGODB_URI。
可以在 https://devcenter.heroku.com/articles/mongolab 找到更多信息。