What is Spring Boot application.properties/application.yaml?

Why Interviewers Ask This

Interviewers use this question to quickly assess whether a candidate has the foundational knowledge required for Spring Boot development. It reveals whether you understand the building blocks that more complex concepts rely on.

Answer

Spring Boot uses application.properties or application.yaml (in src/main/resources/) as the primary configuration file for setting application properties. They configure both Spring Boot auto-configuration and custom application settings. Properties format: server.port=8080 spring.datasource.url=jdbc:postgresql://localhost:5432/mydb spring.datasource.username=postgres spring.datasource.password=secret spring.jpa.hibernate.ddl-auto=validate spring.jpa.show-sql=true logging.level.com.example=DEBUG app.jwt.secret=mySecretKey app.max-upload-size=10MB. YAML format (recommended for hierarchy): server: port: 8080 spring: datasource: url: jdbc:postgresql://localhost:5432/mydb username: postgres jpa: show-sql: true app: jwt: secret: mySecretKey. Profiles: create application-dev.properties, application-prod.properties — activated with spring.profiles.active=dev. External config: Spring Boot loads properties in priority order: 1. Command-line args (--server.port=9090); 2. Environment variables (SPRING_DATASOURCE_URL); 3. application-{profile}.properties; 4. application.properties. @Value injection: @Value("${app.jwt.secret}") private String jwtSecret;. @ConfigurationProperties: bind a prefix to a POJO for type-safe configuration: @ConfigurationProperties(prefix = "app.jwt") public class JwtProperties { private String secret; private int expiration; }.

Pro Tip

Demonstrate both theoretical understanding and practical experience. Say what it is, then give an example of how you actually used it in a Spring Boot codebase.