'Java web application not binding with Heroku $PORT

I have made a Java web application and trying to host it on Heroku with a Dockerfile, CMD as :

CMD ["java", "-Dserver.port=$PORT", "-jar", "/usr/local/lib/backend.jar", "--server.port=$PORT"]

And getting the logs as follows:

2022-05-06T06:53:33.599532+00:00 heroku[web.1]: Starting process with command `java -Dserver.port\=\27061 -jar /usr/local/lib/backend.jar --server.port\=\27061`
2022-05-06T06:53:35.445811+00:00 app[web.1]: 199 [main] INFO org.reflections.Reflections - Reflections took 179 ms to scan 1 urls, producing 4 keys and 22 values
2022-05-06T06:53:41.324114+00:00 app[web.1]: 6078 [main] INFO org.reflections.Reflections - Reflections took 58 ms to scan 1 urls, producing 3 keys and 16 values
2022-05-06T06:53:41.544513+00:00 app[web.1]: May 06, 2022 6:53:41 AM org.javawebstack.httpserver.HTTPServer start
2022-05-06T06:53:41.544514+00:00 app[web.1]: INFO: HTTP-Server started on port 1337

I am not getting able to understand that my argument is providing --server.port=27061 but still the HTTP server is starting on port 1337.

I have already seen all the related available answers on Stack Overflow but none works for me.

I am using javawebstack httpserver



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source