How to configure startup parameters for Spring Boot
The startup parameters of Spring Boot can be configured through properties in the application.properties or application.yml files.
- Configure startup parameters in the application.properties file.
- The server is running on port 8080, the database URL is jdbc:mysql://localhost:3306/mydatabase, and the username and password for the database are root and 123456, respectively.
- Configure startup parameters in the application.yml file.
- Server port number is set to 8080, and the Spring framework is configured to connect to a MySQL database at localhost on port 3306 with the username root and password 123456.
These configuration properties can be modified as needed to meet the requirements of different applications. There is a wide range of properties that can be configured, including port numbers, database connection information, log levels, and more.
Also, configuration can be done via command-line parameters, for example:
java -jar myproject.jar --server.port=8080 --spring.datasource.url=jdbc:mysql://localhost:3306/mydatabase --spring.datasource.username=root --spring.datasource.password=123456
Choose the appropriate method based on the actual situation.