Advertisement
Google Ad Slot: content-top
Spring Boot Application Properties
Spring Boot provides a flexible way to configure applications using application.properties or application.yml files. These configuration files help manage database settings, logging, server properties, and more.
Where to Place application.properties?
- Inside the
src/main/resources/directory. - Spring Boot automatically loads this file at runtime
Common Configurations in application.properties
1. Server Configuration
🔹 server.port → Changes the default port (8080 → 8081).
🔹 server.servlet.context-path → Sets the base URL (localhost:8081/myapp).
2. Database Configuration (MySQL Example)
🔹 spring.datasource.url → Database connection URL.
🔹 spring.jpa.database-platform → Specifies the Hibernate dialect.
3. Hibernate & JPA Configuration
🔹 spring.jpa.show-sql → Prints SQL queries in the console.
🔹 spring.jpa.hibernate.ddl-auto → Schema management (update, create, none).
🔹 spring.jpa.properties.hibernate.format_sql → Formats SQL queries.
4. Logging Configuration
🔹 logging.level.root → Set logging level (TRACE, DEBUG, INFO, WARN, ERROR).
🔹 logging.file.name → Save logs to logs/app.log.
Using application.yml (YAML Format)
Equivalent YAML Configuration for the Above Properties: