简体   繁体   中英

Exception deploying Spring Boot app locally with Heroku

I get the following error whenever I run: 'heroku local web'

.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 looks like this:

web: java -Dserver.port=$PORT -jar build/libs/gs-spring-boot-0.1.0.jar

I am able to deploy to heroku, but I would like to be able to run locally to verify deployment before deploying remotely.

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?

On Windows, you need to reference environment variables like %PORT% instead of the $ notation, which is *nix specific.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM