Customizing Spring Boot Application Port
Spring Boot applications typically listen on port 8080 by default. However, you may need to configure a different port for various reasons. Here are the steps to do so:
System Property Configuration
You can configure the server port using the -Dserver.port=PORT_NUMBER system property:
java -jar my-app.jar -Dserver.port=8090
Application Properties/YAML Configuration
Alternatively, you can create an application.properties file in /src/main/resources/ and add the following:
server.port=8090
For a random port, set the value to 0:
server.port=0
For YAML configuration, create an application.yml file in /src/main/resources/ and include:
server: port: 8090
By using these methods, you can configure the port listened on by your Spring Boot application to the desired value.
The above is the detailed content of How Can I Change the Default Port of My Spring Boot Application?. For more information, please follow other related articles on the PHP Chinese website!