How to change default 8080 port in SpringBoot?
My SpringBoot hello world program by default starting on 8080 port. How can I change this to my desired port?
1 Answer
5 years ago by Eleven
There are couple of ways provided by spring to change the port.
1. Adding configuration in application.properties ( easiest way )
If you are already using the application.properties
in your application then great all you need to do is just add the following line to your application.properties
file
server.port = 8888
If you do not have application.properties
in your application then simply create a new one in src/main/resources
2. Pass it as VM arguments
Let say your application is already packaged (for example as a fat jar) then you will have options to change the code, in those cases you can always pass the following VM Arguments to change the default port.
-Dserver.port=8888
5 years ago by Karthik Divi