Spring Boot

Application Properties & YAML

Configuration with application.properties/yml, @Value, @ConfigurationProperties, profiles, external properties

16 면접 질문·
Junior
1

What is the main difference between application.properties and application.yml in Spring Boot?

답변

Both files are used to configure Spring Boot, but use different formats. YAML format (.yml) allows hierarchical structure with indentation, making it more readable for complex configurations. Properties format (.properties) uses flat key=value syntax. Spring Boot automatically loads either one, with priority to .properties if both exist.

2

Which property allows changing the embedded server port in Spring Boot?

답변

The server.port property configures the HTTP port of the embedded server (Tomcat, Jetty, Undertow). By default, Spring Boot starts on port 8080. This property can be defined in application.properties (server.port=9000) or in YAML (server: port: 9000). It can also be overridden via JVM argument (-Dserver.port=9000) or environment variable.

3

How to declare the property spring.datasource.url in YAML for a local PostgreSQL database?

답변

In YAML, hierarchical properties use indentation (spaces, not tabs). The property spring.datasource.url breaks down into spring → datasource → url. Each level is indented by 2 spaces. This hierarchical structure makes configuration more readable than the flat properties version (spring.datasource.url=jdbc:postgresql://localhost:5432/mydb).

4

How to activate the 'dev' profile at startup of a Spring Boot application?

5

Which annotation allows injecting a configuration property into a Spring bean?

+13 면접 질문

다음 면접을 위해 Spring Boot을 마스터하세요

모든 질문, flashcards, 기술 테스트, 코드 리뷰 연습, 면접 시뮬레이터에 접근하세요.

무료로 시작하기