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.
application.properties
?src/main/resources/
directory.application.properties
🔹 server.port
→ Changes the default port (8080 → 8081).
🔹 server.servlet.context-path
→ Sets the base URL (localhost:8081/myapp
).
🔹 spring.datasource.url
→ Database connection URL.
🔹 spring.jpa.database-platform
→ Specifies the Hibernate dialect.
🔹 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.
🔹 logging.level.root
→ Set logging level (TRACE
, DEBUG
, INFO
, WARN
, ERROR
).
🔹 logging.file.name
→ Save logs to logs/app.log
.
application.yml
(YAML Format)Equivalent YAML Configuration for the Above Properties: