The application.properties
file in Spring Boot serves as a central hub for configuring various aspects of your application. By specifying key-value pairs, you can fine-tune behaviors ranging from server settings to data source configurations. Here's a concise overview:
Common Configuration Categories
-
Server Configuration
-
Port: Define the HTTP port your application listens on.
server.port=8080
-
Context Path: Set the base URI for your application.
server.servlet.context-path=/myapp
-
Port: Define the HTTP port your application listens on.
-
Logging Configuration
-
Log Level: Adjust the verbosity of logs for specific packages.
logging.level.org.springframework=DEBUG
-
Log File: Specify the file to write logs to.
logging.file.name=app.log
-
Log Level: Adjust the verbosity of logs for specific packages.
-
Data Source Configuration
-
Database URL: Set the JDBC URL for your database.
spring.datasource.url=jdbc:mysql://localhost:3306/mydb
-
Credentials: Provide database username and password.
spring.datasource.username=root
spring.datasource.password=secret
-
Database URL: Set the JDBC URL for your database.
-
Spring MVC Configuration
-
View Prefix/Suffix: Define the location and file extension for view templates.
spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp
-
View Prefix/Suffix: Define the location and file extension for view templates.
-
Internationalization (i18n)
-
Locale: Set the default locale for your application.
spring.mvc.locale=en_US
-
Message Source: Specify the basename for message properties.
spring.messages.basename=messages
-
Locale: Set the default locale for your application.
-
Security Configuration
-
Enable Security: Toggle Spring Security for your application.
spring.security.enabled=true
-
User Credentials: Define default user details.
spring.security.user.name=admin
spring.security.user.password=admin
-
Enable Security: Toggle Spring Security for your application.
-
Actuator Endpoints
-
Enable All Endpoints: Expose all actuator endpoints.
management.endpoints.web.exposure.include=*
-
Health Endpoint: Customize health check settings.
management.endpoint.health.show-details=always
-
Enable All Endpoints: Expose all actuator endpoints.
-
Custom Application Properties
- Define your own properties for use within the application.
app.feature.enabled=true
app.service.timeout=5000
- Define your own properties for use within the application.
Comprehensive Resource
For an exhaustive list of available properties and their descriptions, refer to the official Spring Boot documentation:
Common Application Properties: (docs.spring.io)
Top comments (0)