Failed to bind properties under 'server.port' to java.lang.Integer
Asked Answered
T

1

12

Some time ago I faced with such issue:

Failed to bind properties under 'server.port' to java.lang.Integer:

    Property: server.port
    Value: $PORT
    Origin: "server.port" from property source "systemProperties"
    Reason: failed to convert java.lang.String to java.lang.Integer

Action:

Update your application's configuration

I tried to run my docker container in DigitalOcean. I observed some similar topics here and I tried to apply advices. For instance I added server.port=${PORT:8080} to my application.properties but it didn't work for me.

Here's my docker run command:

docker run -p 8080:8080 --name nostalgia --env-file vars.txt --rm -it registry.digitalocean.com/alex-registry/nostalgia

And this is my vars.txt (only one variable at the moment):

PORT=8080

Also I should say that I tried another form of command:

docker run -p 8080:8080 --name nostalgia -e PORT=8080 --rm -it registry.digitalocean.com/alex-registry/nostalgia

But result is the same. What should I do next to overcome this issue and successfully launch the container? Thanks for your answers!!!

Twitter answered 20/12, 2020 at 17:57 Comment(3)
Were you able to figure this out? I'm curious to know the solution.Drag
The thing is that it was long time ago and I don't remember the solution. I'm sorry that I didn't write it down.Twitter
Alright, thanks for the update.Drag
S
0

You overwrite your server.port (Int) with docker env file (String). Just set your application property to server.port=8080 and remove the env file from your docker command.

If you need different port configurations you can do one of the following:

  • work with multiple application.property files
  • overwrite spring boot tomcat property directly in your docker command: -e SERVER_PORT=8080
Senegambia answered 8/5, 2023 at 9:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.