使用Heroku在本地部署Spring Boot应用程序时出现异常 [英] Exception deploying Spring Boot app locally with Heroku
问题描述
每当我运行时,我都会收到以下错误:'heroku local web'
$ b
I get the following error whenever I run: 'heroku local web'
.springframework.core.convert.ConversionFailedException:未能从类型[java.lang.String]转换为类型[java.lang.Integer]为'$ PORT';嵌套异常是java.lang.NumberFormatException:对于输入字符串:$ PORT
.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [java.lang.Integer] for value '$PORT'; nested exception is java.lang.NumberFormatException: For input string: "$PORT"
My Procfile看起来像这样:
My Procfile looks like this:
web:java -Dserver.port = $ PORT -jar build / libs / gs-spring-boot-0.1.0.jar
web: java -Dserver.port=$PORT -jar build/libs/gs-spring-boot-0.1.0.jar
我可以部署到heroku,但我希望能够在本地运行以在远程部署前验证部署。
I am able to deploy to heroku, but I would like to be able to run locally to verify deployment before deploying remotely.
我有一个windows PORT系统环境变量,一个Heroku配置变量设置为'heroku config:set PORT = 8080。'我独立设置了每个这些变量,但没有改变上述错误。任何人都知道为什么我得到这个?
I have a windows PORT system environment variable, and a Heroku config variable set with 'heroku config:set PORT=8080.' I set each of these independently with no change in the above error. Anyone know why I getting this?
推荐答案
在Windows上,您需要引用环境变量,如%PORT %
而不是 $
表示法,它是* nix特定的。
On Windows, you need to reference environment variables like %PORT%
instead of the $
notation, which is *nix specific.
这应该创建一个包含以下内容的 Procfile.windows
文件:
To fix this, you should create a Procfile.windows
file with these contents:
web: java -Dserver.port=%PORT% -jar build\libs\gs-spring-boot-0.1.0.jar
然后执行以下命令:
And then run this command:
heroku local web -f Procfile.windows
这篇关于使用Heroku在本地部署Spring Boot应用程序时出现异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!