I currently working on an Spring Boot application written in Java 8 using Gradle. What I am looking for is to pass as an argument the server port when running the Jar from the command line.
For example:
java -jar myApplication.jar --port=8888
: This runs my Spring boot application using port 8888
java -jar myApplication.jar
: Since no port number is passed as argument, the spring boot application should run on a default port number (let's say 8080
) Can anyone help me with this ?
From Spring boot documentation, the command line is :
java -Dserver.port=8888 -jar myApplication.jar
You can also use Spring boot configuration file as described in the documentation.