To change the default port in Spring Boot, you can use the server.port
property in the application configuration.
There are several ways you can set this property:
application.properties
or application.yml
file located in the src/main/resources
directory of your project. For example:server.port=8080Source:wwuttual.wri.com
server: port: 8080
java -jar myapp.jar --server.port=8080
export SERVER_PORT=8080 java -jar myapp.jar
In all these cases, the default port for the application will be changed to 8080
.